From c41a56e4a29775696cdc693946053ef2c1b5db29 Mon Sep 17 00:00:00 2001 From: Terrtia Date: Fri, 1 Jun 2018 13:36:08 +0200 Subject: [PATCH] clean Flask_tags + gitignore --- .gitignore | 13 ++++++++--- var/www/modules/Tags/Flask_Tags.py | 37 +++++++++++------------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index d62fbd8b..4a266743 100644 --- a/.gitignore +++ b/.gitignore @@ -7,10 +7,15 @@ AILENV redis-leveldb redis +ardb +faup +tlsh Blooms LEVEL_DB_DATA PASTES -bin/indexdir/ +BASE64 +DATA_ARDB +indexdir/ logs/ # Webstuff @@ -20,7 +25,7 @@ var/www/static/ !var/www/static/js/moduleTrending.js !var/www/static/js/plot-graph.js !var/www/static/js/trendingchart.js -var/www/templates/header.html # auto-generated +var/www/templates/header.html # Local config bin/packages/config.cfg @@ -28,4 +33,6 @@ bin/packages/config.cfg # installed files nltk_data/ doc/all_modules.txt -doc/module-data-flow.png # auto-generated +# auto generated +doc/module-data-flow.png +doc/data-flow.png diff --git a/var/www/modules/Tags/Flask_Tags.py b/var/www/modules/Tags/Flask_Tags.py index 95560ad6..a8dd4c8b 100644 --- a/var/www/modules/Tags/Flask_Tags.py +++ b/var/www/modules/Tags/Flask_Tags.py @@ -52,6 +52,18 @@ for name, tags in clusters.items(): #galaxie name + tags def one(): return 1 +def get_tags_with_synonyms(tag): + str_synonyms = ' - synonyms: ' + synonyms = r_serv_tags.smembers('synonym_tag_' + tag) + # synonyms to display + for synonym in synonyms: + str_synonyms = str_synonyms + synonym + ', ' + # add real tag + if str_synonyms != ' - synonyms: ': + return {'name':tag + str_synonyms,'id':tag} + else: + return {'name':tag,'id':tag} + # ============= ROUTES ============== @Tags.route("/Tags/", methods=['GET']) @@ -106,16 +118,7 @@ def get_all_tags_galaxy(): for galaxy in active_galaxies: l_tags = r_serv_tags.smembers('active_tag_galaxies_' + galaxy) for tag in l_tags: - str_synonyms = ' - synonyms: ' - synonyms = r_serv_tags.smembers('synonym_tag_' + tag) - # synonyms to display - for synonym in synonyms: - str_synonyms = str_synonyms + synonym + ', ' - # add real tag - if str_synonyms != ' - synonyms: ': - list_tags.append({'name':tag + str_synonyms,'id':tag}) - else: - list_tags.append({'name':tag,'id':tag}) + list_tags.append(get_tags_with_synonyms(tag)) return jsonify(list_tags) @@ -134,7 +137,6 @@ def get_tags_taxonomie(): if taxonomie in active_taxonomie: list_tags = [] - #l_tags = taxonomies.get(taxonomie).machinetags() l_tags = r_serv_tags.smembers('active_tag_' + taxonomie) for tag in l_tags: list_tags.append( tag ) @@ -159,15 +161,7 @@ def get_tags_galaxy(): list_tags = [] l_tags = r_serv_tags.smembers('active_tag_galaxies_' + galaxy) for tag in l_tags: - synonyms = r_serv_tags.smembers('synonym_tag_' + tag) - str_synonyms = ' - synonyms: ' - for synonym in synonyms: - str_synonyms = str_synonyms + synonym + ', ' - # add real tag - if str_synonyms != ' - synonyms: ': - list_tags.append({'name':tag + str_synonyms,'id':tag}) - else: - list_tags.append({'name':tag,'id':tag}) + list_tags.append(get_tags_with_synonyms(tag)) return jsonify(list_tags) @@ -601,9 +595,6 @@ def edit_galaxy(): for data in val: try: meta = data['meta'] - '''synonyms = meta['synonyms'] - logo = meta['logo'] - refs = meta['refs']''' except KeyError: meta = [] tag_name = data['value']