From d950556fcc613ed0d348163fd1a015fbfbc92724 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 17 Nov 2013 22:25:10 +0100 Subject: Minor improvements in utils.py. --- pyaggr3g470r/utils.py | 28 ++++------------------------ pyaggr3g470r/views.py | 2 +- 2 files changed, 5 insertions(+), 25 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py index 398cfab3..c214cf71 100755 --- a/pyaggr3g470r/utils.py +++ b/pyaggr3g470r/utils.py @@ -20,9 +20,9 @@ # along with this program. If not, see __author__ = "Cedric Bonhomme" -__version__ = "$Revision: 1.5 $" +__version__ = "$Revision: 1.6 $" __date__ = "$Date: 2010/12/07 $" -__revision__ = "$Date: 2013/07/24 $" +__revision__ = "$Date: 2013/11/17 $" __copyright__ = "Copyright (c) Cedric Bonhomme" __license__ = "GPLv3" @@ -109,16 +109,6 @@ def clear_string(data): q = re.compile('\s') # consecutive white spaces return p.sub('', q.sub(' ', data)) -def normalize_filename(name): - """ - Normalize a file name. - """ - file_name = re.sub("[,'!?|&]", "", name) - file_name = re.sub("[\s.]", "_", file_name) - file_name = file_name.strip('_') - file_name = file_name.strip('.') - return os.path.normpath(file_name) - def load_stop_words(): """ Load the stop words and return them in a list. @@ -148,24 +138,14 @@ def top_words(articles, n=10, size=5): words[word] += 1 return words.most_common(n) -def tag_cloud(tags, query="word_count"): +def tag_cloud(tags): """ Generates a tags cloud. """ tags.sort(key=operator.itemgetter(0)) - if query == "word_count": - # tags cloud from the management page - return ' '.join([('%s\n' % \ + return '\n'.join([('%s' % \ (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), word, format(count, ',d'), word)) \ for (word, count) in tags]) - if query == "year": - # tags cloud for the history - return ' '.join([('%s\n' % \ - (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), query, word, format(count, ',d'), word)) \ - for (word, count) in tags]) - return ' '.join([('%s\n' % \ - (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), query, word, format(count, ',d'), calendar.month_name[int(word)])) \ - for (word, count) in tags]) def search_feed(url): """ diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index d44b3d60..7b156b9f 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -125,7 +125,7 @@ def feeds(): @app.route('/feed/', methods=['GET']) @login_required def feed(feed_id=None): - word_size = 5 + word_size = 6 user = models.User.objects(email=g.user.email, feeds__oid=feed_id).first() for feed in user.feeds: if str(feed.oid) == feed_id: -- cgit