From 9814b817971d76afb0b273f392ba5852f43a274d Mon Sep 17 00:00:00 2001 From: volpino Date: Tue, 27 Mar 2012 18:45:35 +0200 Subject: [PATCH 1/4] adding setuptools to setup.py --- .gitignore | 5 +++-- setup.py | 30 +++++++++++++++++++----------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index ee88a09..05fad2e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *~ -*.pyc +*.py[co] euscanwww/rrd/*.rrd -euscanwww/media/charts/*.png \ No newline at end of file +euscanwww/media/charts/*.png +*.egg-info diff --git a/setup.py b/setup.py index 048a5fe..67aa5c5 100755 --- a/setup.py +++ b/setup.py @@ -4,8 +4,11 @@ from __future__ import print_function import re import sys -import distutils -from distutils import core, log +from distutils import log +try: + from setuptools import setup, Command +except ImportError: + from distutils.core import setup, Command from glob import glob import os @@ -21,27 +24,29 @@ cwd = os.getcwd() try: from portage.const import EPREFIX except ImportError: - EPREFIX='' + EPREFIX = '' # Python files that need `__version__ = ""` subbed, relative to this dir: python_scripts = [os.path.join(cwd, path) for path in ( 'bin/euscan', )] -class set_version(core.Command): + +class set_version(Command): """Set python __version__ to our __version__.""" description = "hardcode scripts' version using VERSION from environment" user_options = [] # [(long_name, short_name, desc),] - def initialize_options (self): + def initialize_options(self): pass - def finalize_options (self): + def finalize_options(self): pass def run(self): ver = 'git' if __version__ == '9999' else __version__ print("Settings version to %s" % ver) + def sub(files, pattern): for f in files: updated_file = [] @@ -63,7 +68,7 @@ packages = [ if '__init__.py' in files ] -core.setup( +setup( name='euscan', version=__version__, description='Ebuild upstream scan utility.', @@ -72,16 +77,19 @@ core.setup( maintainer='Corentin Chary', maintainer_email='corentin.chary@gmail.com', url='http://euscan.iksaif.net', - download_url='https://github.com/iksaif/euscan/tarball/' + ('master' if __version__ == '9999' else ('euscan-%s' % __version__)), + download_url=( + 'https://github.com/iksaif/euscan/tarball/' + + ('master' if __version__ == '9999' else ('euscan-%s' % __version__)) + ), package_dir={'': 'pym'}, packages=packages, - package_data = {}, + package_data={}, scripts=python_scripts, data_files=( - (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'usr/share/man/man1'), glob('man/*')), + (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'usr/share/man/man1'), + glob('man/*')), ), cmdclass={ 'set_version': set_version, }, ) - From ac6c57cb57aa92764bb7e5a07264f5a59a4c87ff Mon Sep 17 00:00:00 2001 From: volpino Date: Tue, 27 Mar 2012 18:48:31 +0200 Subject: [PATCH 2/4] adding django-annoying to requirements and deleting it from the codebase --- euscanwww/annoying/__init__.py | 0 euscanwww/annoying/decorators.py | 194 ---------------- euscanwww/annoying/exceptions.py | 5 - euscanwww/annoying/fields.py | 69 ------ euscanwww/annoying/functions.py | 32 --- euscanwww/annoying/middlewares.py | 32 --- euscanwww/annoying/templatetags/__init__.py | 0 euscanwww/annoying/templatetags/annoying.py | 14 -- euscanwww/annoying/templatetags/smart_if.py | 240 -------------------- euscanwww/annoying/utils.py | 26 --- setup.py | 1 + 11 files changed, 1 insertion(+), 612 deletions(-) delete mode 100644 euscanwww/annoying/__init__.py delete mode 100644 euscanwww/annoying/decorators.py delete mode 100644 euscanwww/annoying/exceptions.py delete mode 100644 euscanwww/annoying/fields.py delete mode 100644 euscanwww/annoying/functions.py delete mode 100644 euscanwww/annoying/middlewares.py delete mode 100644 euscanwww/annoying/templatetags/__init__.py delete mode 100644 euscanwww/annoying/templatetags/annoying.py delete mode 100644 euscanwww/annoying/templatetags/smart_if.py delete mode 100644 euscanwww/annoying/utils.py diff --git a/euscanwww/annoying/__init__.py b/euscanwww/annoying/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/euscanwww/annoying/decorators.py b/euscanwww/annoying/decorators.py deleted file mode 100644 index 86655c5..0000000 --- a/euscanwww/annoying/decorators.py +++ /dev/null @@ -1,194 +0,0 @@ -from django.shortcuts import render_to_response -from django import forms -from django.template import RequestContext -from django.db.models import signals as signalmodule -from django.http import HttpResponse -from django.utils import simplejson - -__all__ = ['render_to', 'signals', 'ajax_request', 'autostrip'] - - -try: - from functools import wraps -except ImportError: - def wraps(wrapped, assigned=('__module__', '__name__', '__doc__'), - updated=('__dict__',)): - def inner(wrapper): - for attr in assigned: - setattr(wrapper, attr, getattr(wrapped, attr)) - for attr in updated: - getattr(wrapper, attr).update(getattr(wrapped, attr, {})) - return wrapper - return inner - - -def render_to(template=None, mimetype=None): - """ - Decorator for Django views that sends returned dict to render_to_response - function. - - Template name can be decorator parameter or TEMPLATE item in returned - dictionary. RequestContext always added as context instance. - If view doesn't return dict then decorator simply returns output. - - Parameters: - - template: template name to use - - mimetype: content type to send in response headers - - Examples: - # 1. Template name in decorator parameters - - @render_to('template.html') - def foo(request): - bar = Bar.object.all() - return {'bar': bar} - - # equals to - def foo(request): - bar = Bar.object.all() - return render_to_response('template.html', - {'bar': bar}, - context_instance=RequestContext(request)) - - - # 2. Template name as TEMPLATE item value in return dictionary. - if TEMPLATE is given then its value will have higher priority - than render_to argument. - - @render_to() - def foo(request, category): - template_name = '%s.html' % category - return {'bar': bar, 'TEMPLATE': template_name} - - #equals to - def foo(request, category): - template_name = '%s.html' % category - return render_to_response(template_name, - {'bar': bar}, - context_instance=RequestContext(request)) - - """ - def renderer(function): - @wraps(function) - def wrapper(request, *args, **kwargs): - output = function(request, *args, **kwargs) - if not isinstance(output, dict): - return output - tmpl = output.pop('TEMPLATE', template) - return render_to_response(tmpl, output, \ - context_instance=RequestContext(request), mimetype=mimetype) - return wrapper - return renderer - - - -class Signals(object): - ''' - Convenient wrapper for working with Django's signals (or any other - implementation using same API). - - Example of usage:: - - - # connect to registered signal - @signals.post_save(sender=YourModel) - def sighandler(instance, **kwargs): - pass - - # connect to any signal - signals.register_signal(siginstance, signame) # and then as in example above - - or - - @signals(siginstance, sender=YourModel) - def sighandler(instance, **kwargs): - pass - - In any case defined function will remain as is, without any changes. - - (c) 2008 Alexander Solovyov, new BSD License - ''' - def __init__(self): - self._signals = {} - - # register all Django's default signals - for k, v in signalmodule.__dict__.iteritems(): - # that's hardcode, but IMHO it's better than isinstance - if not k.startswith('__') and k != 'Signal': - self.register_signal(v, k) - - def __getattr__(self, name): - return self._connect(self._signals[name]) - - def __call__(self, signal, **kwargs): - def inner(func): - signal.connect(func, **kwargs) - return func - return inner - - def _connect(self, signal): - def wrapper(**kwargs): - return self(signal, **kwargs) - return wrapper - - def register_signal(self, signal, name): - self._signals[name] = signal - -signals = Signals() - - - -class JsonResponse(HttpResponse): - """ - HttpResponse descendant, which return response with ``application/json`` mimetype. - """ - def __init__(self, data): - super(JsonResponse, self).__init__(content=simplejson.dumps(data), mimetype='application/json') - - - -def ajax_request(func): - """ - If view returned serializable dict, returns JsonResponse with this dict as content. - - example: - - @ajax_request - def my_view(request): - news = News.objects.all() - news_titles = [entry.title for entry in news] - return {'news_titles': news_titles} - """ - @wraps(func) - def wrapper(request, *args, **kwargs): - response = func(request, *args, **kwargs) - if isinstance(response, dict): - return JsonResponse(response) - else: - return response - return wrapper - - -def autostrip(cls): - """ - strip text fields before validation - - example: - class PersonForm(forms.Form): - name = forms.CharField(min_length=2, max_length=10) - email = forms.EmailField() - - PersonForm = autostrip(PersonForm) - - #or you can use @autostrip in python >= 2.6 - - Author: nail.xx - """ - fields = [(key, value) for key, value in cls.base_fields.iteritems() if isinstance(value, forms.CharField)] - for field_name, field_object in fields: - def get_clean_func(original_clean): - return lambda value: original_clean(value and value.strip()) - clean_func = get_clean_func(getattr(field_object, 'clean')) - setattr(field_object, 'clean', clean_func) - return cls - diff --git a/euscanwww/annoying/exceptions.py b/euscanwww/annoying/exceptions.py deleted file mode 100644 index 1cef123..0000000 --- a/euscanwww/annoying/exceptions.py +++ /dev/null @@ -1,5 +0,0 @@ -class Redirect(Exception): - def __init__(self, *args, **kwargs): - self.args = args - self.kwargs = kwargs - diff --git a/euscanwww/annoying/fields.py b/euscanwww/annoying/fields.py deleted file mode 100644 index 3b3725c..0000000 --- a/euscanwww/annoying/fields.py +++ /dev/null @@ -1,69 +0,0 @@ -from django.db import models -from django.db.models import OneToOneField -from django.utils import simplejson as json -from django.core.serializers.json import DjangoJSONEncoder -from django.db.models.fields.related import SingleRelatedObjectDescriptor - - -class AutoSingleRelatedObjectDescriptor(SingleRelatedObjectDescriptor): - def __get__(self, instance, instance_type=None): - try: - return super(AutoSingleRelatedObjectDescriptor, self).__get__(instance, instance_type) - except self.related.model.DoesNotExist: - obj = self.related.model(**{self.related.field.name: instance}) - obj.save() - return obj - - -class AutoOneToOneField(OneToOneField): - ''' - OneToOneField creates related object on first call if it doesnt exist yet. - Use it instead of original OneToOne field. - - example: - - class MyProfile(models.Model): - user = AutoOneToOneField(User, primary_key=True) - home_page = models.URLField(max_length=255, blank=True) - icq = models.IntegerField(max_length=255, null=True) - ''' - def contribute_to_related_class(self, cls, related): - setattr(cls, related.get_accessor_name(), AutoSingleRelatedObjectDescriptor(related)) - - -class JSONField(models.TextField): - """ - JSONField is a generic textfield that neatly serializes/unserializes - JSON objects seamlessly. - Django snippet #1478 - - example: - class Page(models.Model): - data = JSONField(blank=True, null=True) - - - page = Page.objects.get(pk=5) - page.data = {'title': 'test', 'type': 3} - page.save() - """ - - __metaclass__ = models.SubfieldBase - - def to_python(self, value): - if value == "": - return None - - try: - if isinstance(value, basestring): - return json.loads(value) - except ValueError: - pass - return value - - def get_db_prep_save(self, value, *args, **kwargs): - if value == "": - return None - if isinstance(value, dict): - value = json.dumps(value, cls=DjangoJSONEncoder) - return super(JSONField, self).get_db_prep_save(value, *args, **kwargs) - diff --git a/euscanwww/annoying/functions.py b/euscanwww/annoying/functions.py deleted file mode 100644 index 7b7f49a..0000000 --- a/euscanwww/annoying/functions.py +++ /dev/null @@ -1,32 +0,0 @@ -from django.shortcuts import _get_queryset -from django.conf import settings - - -def get_object_or_None(klass, *args, **kwargs): - """ - Uses get() to return an object or None if the object does not exist. - - klass may be a Model, Manager, or QuerySet object. All other passed - arguments and keyword arguments are used in the get() query. - - Note: Like with get(), a MultipleObjectsReturned will be raised if more than one - object is found. - """ - queryset = _get_queryset(klass) - try: - return queryset.get(*args, **kwargs) - except queryset.model.DoesNotExist: - return None - - - -def get_config(key, default): - """ - Get settings from django.conf if exists, - return default value otherwise - - example: - - ADMIN_EMAIL = get_config('ADMIN_EMAIL', 'default@email.com') - """ - return getattr(settings, key, default) diff --git a/euscanwww/annoying/middlewares.py b/euscanwww/annoying/middlewares.py deleted file mode 100644 index 8075a12..0000000 --- a/euscanwww/annoying/middlewares.py +++ /dev/null @@ -1,32 +0,0 @@ -import re - -from django.conf import settings -from django.views.static import serve -from django.shortcuts import redirect - -from .exceptions import Redirect - - -class StaticServe(object): - """ - Django middleware for serving static files instead of using urls.py - """ - regex = re.compile(r'^%s(?P.*)$' % settings.MEDIA_URL) - - def process_request(self, request): - if settings.DEBUG: - match = self.regex.search(request.path) - if match: - return serve(request, match.group(1), settings.MEDIA_ROOT) - - -class RedirectMiddleware(object): - """ - You must add this middleware to MIDDLEWARE_CLASSES list, - to make work Redirect exception. All arguments passed to - Redirect will be passed to django built in redirect function. - """ - def process_exception(self, request, exception): - if not isinstance(exception, Redirect): - return - return redirect(*exception.args, **exception.kwargs) diff --git a/euscanwww/annoying/templatetags/__init__.py b/euscanwww/annoying/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/euscanwww/annoying/templatetags/annoying.py b/euscanwww/annoying/templatetags/annoying.py deleted file mode 100644 index 1d92526..0000000 --- a/euscanwww/annoying/templatetags/annoying.py +++ /dev/null @@ -1,14 +0,0 @@ -import django -from django import template - -from smart_if import smart_if - - -register = template.Library() - - -try: - if int(django.get_version()[-5:]) < 11806: - register.tag('if', smart_if) -except ValueError: - pass diff --git a/euscanwww/annoying/templatetags/smart_if.py b/euscanwww/annoying/templatetags/smart_if.py deleted file mode 100644 index 9839690..0000000 --- a/euscanwww/annoying/templatetags/smart_if.py +++ /dev/null @@ -1,240 +0,0 @@ -from django import template - -__author__ = "SmileyChris" - -#============================================================================== -# Calculation objects -#============================================================================== - -class BaseCalc(object): - def __init__(self, var1, var2=None, negate=False): - self.var1 = var1 - self.var2 = var2 - self.negate = negate - - def resolve(self, context): - try: - var1, var2 = self.resolve_vars(context) - outcome = self.calculate(var1, var2) - except: - outcome = False - if self.negate: - return not outcome - return outcome - - def resolve_vars(self, context): - var2 = self.var2 and self.var2.resolve(context) - return self.var1.resolve(context), var2 - - def calculate(self, var1, var2): - raise NotImplementedError() - - -class Or(BaseCalc): - def calculate(self, var1, var2): - return var1 or var2 - - -class And(BaseCalc): - def calculate(self, var1, var2): - return var1 and var2 - - -class Equals(BaseCalc): - def calculate(self, var1, var2): - return var1 == var2 - - -class Greater(BaseCalc): - def calculate(self, var1, var2): - return var1 > var2 - - -class GreaterOrEqual(BaseCalc): - def calculate(self, var1, var2): - return var1 >= var2 - - -class In(BaseCalc): - def calculate(self, var1, var2): - return var1 in var2 - - -OPERATORS = { - '=': (Equals, True), - '==': (Equals, True), - '!=': (Equals, False), - '>': (Greater, True), - '>=': (GreaterOrEqual, True), - '<=': (Greater, False), - '<': (GreaterOrEqual, False), - 'or': (Or, True), - 'and': (And, True), - 'in': (In, True), -} -BOOL_OPERATORS = ('or', 'and') - - -class IfParser(object): - error_class = ValueError - - def __init__(self, tokens): - self.tokens = tokens - - def _get_tokens(self): - return self._tokens - - def _set_tokens(self, tokens): - self._tokens = tokens - self.len = len(tokens) - self.pos = 0 - - tokens = property(_get_tokens, _set_tokens) - - def parse(self): - if self.at_end(): - raise self.error_class('No variables provided.') - var1 = self.get_bool_var() - while not self.at_end(): - op, negate = self.get_operator() - var2 = self.get_bool_var() - var1 = op(var1, var2, negate=negate) - return var1 - - def get_token(self, eof_message=None, lookahead=False): - negate = True - token = None - pos = self.pos - while token is None or token == 'not': - if pos >= self.len: - if eof_message is None: - raise self.error_class() - raise self.error_class(eof_message) - token = self.tokens[pos] - negate = not negate - pos += 1 - if not lookahead: - self.pos = pos - return token, negate - - def at_end(self): - return self.pos >= self.len - - def create_var(self, value): - return TestVar(value) - - def get_bool_var(self): - """ - Returns either a variable by itself or a non-boolean operation (such as - ``x == 0`` or ``x < 0``). - - This is needed to keep correct precedence for boolean operations (i.e. - ``x or x == 0`` should be ``x or (x == 0)``, not ``(x or x) == 0``). - """ - var = self.get_var() - if not self.at_end(): - op_token = self.get_token(lookahead=True)[0] - if isinstance(op_token, basestring) and (op_token not in - BOOL_OPERATORS): - op, negate = self.get_operator() - return op(var, self.get_var(), negate=negate) - return var - - def get_var(self): - token, negate = self.get_token('Reached end of statement, still ' - 'expecting a variable.') - if isinstance(token, basestring) and token in OPERATORS: - raise self.error_class('Expected variable, got operator (%s).' % - token) - var = self.create_var(token) - if negate: - return Or(var, negate=True) - return var - - def get_operator(self): - token, negate = self.get_token('Reached end of statement, still ' - 'expecting an operator.') - if not isinstance(token, basestring) or token not in OPERATORS: - raise self.error_class('%s is not a valid operator.' % token) - if self.at_end(): - raise self.error_class('No variable provided after "%s".' % token) - op, true = OPERATORS[token] - if not true: - negate = not negate - return op, negate - - -#============================================================================== -# Actual templatetag code. -#============================================================================== - -class TemplateIfParser(IfParser): - error_class = template.TemplateSyntaxError - - def __init__(self, parser, *args, **kwargs): - self.template_parser = parser - return super(TemplateIfParser, self).__init__(*args, **kwargs) - - def create_var(self, value): - return self.template_parser.compile_filter(value) - - -class SmartIfNode(template.Node): - def __init__(self, var, nodelist_true, nodelist_false=None): - self.nodelist_true, self.nodelist_false = nodelist_true, nodelist_false - self.var = var - - def render(self, context): - if self.var.resolve(context): - return self.nodelist_true.render(context) - if self.nodelist_false: - return self.nodelist_false.render(context) - return '' - - def __repr__(self): - return "" - - def __iter__(self): - for node in self.nodelist_true: - yield node - if self.nodelist_false: - for node in self.nodelist_false: - yield node - - def get_nodes_by_type(self, nodetype): - nodes = [] - if isinstance(self, nodetype): - nodes.append(self) - nodes.extend(self.nodelist_true.get_nodes_by_type(nodetype)) - if self.nodelist_false: - nodes.extend(self.nodelist_false.get_nodes_by_type(nodetype)) - return nodes - - -def smart_if(parser, token): - """ - A smarter {% if %} tag for django templates. - - While retaining current Django functionality, it also handles equality, - greater than and less than operators. Some common case examples:: - - {% if articles|length >= 5 %}...{% endif %} - {% if "ifnotequal tag" != "beautiful" %}...{% endif %} - - Arguments and operators _must_ have a space between them, so - ``{% if 1>2 %}`` is not a valid smart if tag. - - All supported operators are: ``or``, ``and``, ``in``, ``=`` (or ``==``), - ``!=``, ``>``, ``>=``, ``<`` and ``<=``. - """ - bits = token.split_contents()[1:] - var = TemplateIfParser(parser, bits).parse() - nodelist_true = parser.parse(('else', 'endif')) - token = parser.next_token() - if token.contents == 'else': - nodelist_false = parser.parse(('endif',)) - parser.delete_first_token() - else: - nodelist_false = None - return SmartIfNode(var, nodelist_true, nodelist_false) - diff --git a/euscanwww/annoying/utils.py b/euscanwww/annoying/utils.py deleted file mode 100644 index 6bb8f06..0000000 --- a/euscanwww/annoying/utils.py +++ /dev/null @@ -1,26 +0,0 @@ -from django.http import HttpResponse -from django.utils.encoding import iri_to_uri - - -class HttpResponseReload(HttpResponse): - """ - Reload page and stay on the same page from where request was made. - - example: - - def simple_view(request): - if request.POST: - form = CommentForm(request.POST): - if form.is_valid(): - form.save() - return HttpResponseReload(request) - else: - form = CommentForm() - return render_to_response('some_template.html', {'form': form}) - """ - status_code = 302 - - def __init__(self, request): - HttpResponse.__init__(self) - referer = request.META.get('HTTP_REFERER') - self['Location'] = iri_to_uri(referer or "/") diff --git a/setup.py b/setup.py index 67aa5c5..3b4eed5 100755 --- a/setup.py +++ b/setup.py @@ -81,6 +81,7 @@ setup( 'https://github.com/iksaif/euscan/tarball/' + ('master' if __version__ == '9999' else ('euscan-%s' % __version__)) ), + install_requires=['django-annoying'], package_dir={'': 'pym'}, packages=packages, package_data={}, From 06bef562e837c2bf6e5c0b003262b2af8bc8b1d2 Mon Sep 17 00:00:00 2001 From: volpino Date: Tue, 27 Mar 2012 18:58:19 +0200 Subject: [PATCH 3/4] cleaning up, pep8 fix and changing tabs to spaces --- bin/euscan | 5 +-- setup.py | 112 ++++++++++++++++++++++++++--------------------------- 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/bin/euscan b/bin/euscan index 6f6463f..19c9ee5 100755 --- a/bin/euscan +++ b/bin/euscan @@ -16,7 +16,6 @@ __version__ = "git" """ Imports """ -import os import sys import getopt import errno @@ -208,7 +207,7 @@ def main(): try: ret = scan_upstream(package) - except AmbiguousPackageName as e: + except AmbiguousPackageName as e: pkgs = e.args[0] for candidate in pkgs: print(candidate) @@ -219,7 +218,7 @@ def main(): print(pp.error("The short ebuild name '%s' is ambiguous. Please specify" % basename(pkgs[0])), file=sys.stderr, end="") pp.die(1, "one of the above fully-qualified ebuild names instead.") - except GentoolkitException as err: + except GentoolkitException as err: pp.die(1, '%s: %s' % (package, str(err))) except Exception as err: pp.die(1, '%s: %s' % (package, str(err))) diff --git a/setup.py b/setup.py index 3b4eed5..f466c1f 100755 --- a/setup.py +++ b/setup.py @@ -6,9 +6,9 @@ import re import sys from distutils import log try: - from setuptools import setup, Command + from setuptools import setup, Command except ImportError: - from distutils.core import setup, Command + from distutils.core import setup, Command from glob import glob import os @@ -22,75 +22,75 @@ cwd = os.getcwd() # Load EPREFIX from Portage, fall back to the empty string if it fails try: - from portage.const import EPREFIX + from portage.const import EPREFIX except ImportError: - EPREFIX = '' + EPREFIX = '' # Python files that need `__version__ = ""` subbed, relative to this dir: python_scripts = [os.path.join(cwd, path) for path in ( - 'bin/euscan', + 'bin/euscan', )] class set_version(Command): - """Set python __version__ to our __version__.""" - description = "hardcode scripts' version using VERSION from environment" - user_options = [] # [(long_name, short_name, desc),] + """Set python __version__ to our __version__.""" + description = "hardcode scripts' version using VERSION from environment" + user_options = [] # [(long_name, short_name, desc),] - def initialize_options(self): - pass + def initialize_options(self): + pass - def finalize_options(self): - pass + def finalize_options(self): + pass - def run(self): - ver = 'git' if __version__ == '9999' else __version__ - print("Settings version to %s" % ver) + def run(self): + ver = 'git' if __version__ == '9999' else __version__ + print("Settings version to %s" % ver) - def sub(files, pattern): - for f in files: - updated_file = [] - with io.open(f, 'r', 1, 'utf_8') as s: - for line in s: - newline = re.sub(pattern, '"%s"' % ver, line, 1) - if newline != line: - log.info("%s: %s" % (f, newline)) - updated_file.append(newline) - with io.open(f, 'w', 1, 'utf_8') as s: - s.writelines(updated_file) - quote = r'[\'"]{1}' - python_re = r'(?<=^__version__ = )' + quote + '[^\'"]*' + quote - sub(python_scripts, python_re) + def sub(files, pattern): + for f in files: + updated_file = [] + with io.open(f, 'r', 1, 'utf_8') as s: + for line in s: + newline = re.sub(pattern, '"%s"' % ver, line, 1) + if newline != line: + log.info("%s: %s" % (f, newline)) + updated_file.append(newline) + with io.open(f, 'w', 1, 'utf_8') as s: + s.writelines(updated_file) + quote = r'[\'"]{1}' + python_re = r'(?<=^__version__ = )' + quote + '[^\'"]*' + quote + sub(python_scripts, python_re) packages = [ - str('.'.join(root.split(os.sep)[1:])) - for root, dirs, files in os.walk('pym/euscan') - if '__init__.py' in files + str('.'.join(root.split(os.sep)[1:])) + for root, dirs, files in os.walk('pym/euscan') + if '__init__.py' in files ] setup( - name='euscan', - version=__version__, - description='Ebuild upstream scan utility.', - author='Corentin Chary', - author_email='corentin.chary@gmail.com', - maintainer='Corentin Chary', - maintainer_email='corentin.chary@gmail.com', - url='http://euscan.iksaif.net', - download_url=( - 'https://github.com/iksaif/euscan/tarball/' + - ('master' if __version__ == '9999' else ('euscan-%s' % __version__)) - ), - install_requires=['django-annoying'], - package_dir={'': 'pym'}, - packages=packages, - package_data={}, - scripts=python_scripts, - data_files=( - (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'usr/share/man/man1'), - glob('man/*')), - ), - cmdclass={ - 'set_version': set_version, - }, + name='euscan', + version=__version__, + description='Ebuild upstream scan utility.', + author='Corentin Chary', + author_email='corentin.chary@gmail.com', + maintainer='Corentin Chary', + maintainer_email='corentin.chary@gmail.com', + url='http://euscan.iksaif.net', + download_url=( + 'https://github.com/iksaif/euscan/tarball/' + + ('master' if __version__ == '9999' else ('euscan-%s' % __version__)) + ), + install_requires=['django-annoying'], + package_dir={'': 'pym'}, + packages=packages, + package_data={}, + scripts=python_scripts, + data_files=( + (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'usr/share/man/man1'), + glob('man/*')), + ), + cmdclass={ + 'set_version': set_version, + }, ) From a7e9a7c101454b1e40894050f89be967d9797e75 Mon Sep 17 00:00:00 2001 From: volpino Date: Tue, 27 Mar 2012 19:11:21 +0200 Subject: [PATCH 4/4] more requirements, some more are missing tough --- .gitignore | 1 + setup.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 05fad2e..8f5f161 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ euscanwww/rrd/*.rrd euscanwww/media/charts/*.png *.egg-info +local_settings.py diff --git a/setup.py b/setup.py index f466c1f..b08e46b 100755 --- a/setup.py +++ b/setup.py @@ -81,7 +81,8 @@ setup( 'https://github.com/iksaif/euscan/tarball/' + ('master' if __version__ == '9999' else ('euscan-%s' % __version__)) ), - install_requires=['django-annoying'], + install_requires=['Django==1.3.1', 'django-annoying', 'South', + 'django-piston', 'matplotlib'], package_dir={'': 'pym'}, packages=packages, package_data={},