harvest-dev team mailing list archive
-
harvest-dev team
-
Mailing list archive
-
Message #00503
[Merge] lp:~arvindsraj/harvest/imports-fixed into lp:harvest
Arvind S Raj has proposed merging lp:~arvindsraj/harvest/imports-fixed into lp:harvest.
Requested reviews:
harvest-dev (harvest-dev)
Related bugs:
#656219 move imports to top of the file
https://bugs.launchpad.net/bugs/656219
Moved all import statements to the top of the file and arranged the statements to conform to PEP 8.
--
https://code.launchpad.net/~arvindsraj/harvest/imports-fixed/+merge/43050
Your team harvest-dev is requested to review the proposed merge of lp:~arvindsraj/harvest/imports-fixed into lp:harvest.
=== modified file 'harvest/common/launchpad.py'
--- harvest/common/launchpad.py 2010-10-08 08:07:25 +0000
+++ harvest/common/launchpad.py 2010-12-08 08:22:15 +0000
@@ -1,7 +1,6 @@
+from django.conf import settings
from launchpadlib.launchpad import Launchpad, EDGE_SERVICE_ROOT
-from django.conf import settings
-
def lp_login(lp_instance=EDGE_SERVICE_ROOT):
"""
Return a logged in Launchpad object.
=== modified file 'harvest/common/opportunity_lists.py'
--- harvest/common/opportunity_lists.py 2010-11-16 12:14:52 +0000
+++ harvest/common/opportunity_lists.py 2010-12-08 08:22:15 +0000
@@ -1,14 +1,20 @@
-LIST_BRANCH_URL = "lp:harvest-data"
-
-from django.conf import settings
-
import csv
+import datetime
+import gzip
+import json
import os
+import socket
+import StringIO
+import time
+import urllib2
+
+
+from django.conf import settings
+
+LIST_BRANCH_URL = "lp:harvest-data"
def read_csv(url, sock):
if url.endswith(".csv.gz"):
- import StringIO
- import gzip
data = gzip.GzipFile(fileobj=StringIO.StringIO(sock.read())).readlines()
else:
data = sock.readlines()
@@ -16,10 +22,7 @@
return [map(unicode, [a for a in l]) for l in csv.reader(lines)]
def read_json(url, sock):
- import json
if url.endswith(".json.gz"):
- import StringIO
- import gzip
data = gzip.GzipFile(fileobj=StringIO.StringIO(sock.read())).read()
else:
data = sock.read()
@@ -35,10 +38,6 @@
return data
def read_entries(url, last_updated):
- import time
- import datetime
- import urllib2
- import socket
try:
socket.setdefaulttimeout(5)
req = urllib2.Request(url)
=== modified file 'harvest/common/templatetags/humanize_timediff.py'
--- harvest/common/templatetags/humanize_timediff.py 2010-08-31 07:55:47 +0000
+++ harvest/common/templatetags/humanize_timediff.py 2010-12-08 08:22:15 +0000
@@ -2,6 +2,8 @@
#filter, but slightly fuzzier.
#From <http://djangosnippets.org/snippets/412/> with localization added
+import datetime
+
from django.utils.translation import ungettext
from django import template
@@ -17,7 +19,6 @@
4 days 5 hours returns '4 days'
0 days 4 hours 3 minutes returns '4 hours', etc...
"""
- import datetime
timeDiff = datetime.datetime.now() - timestamp
days = timeDiff.days
=== modified file 'harvest/common/utils.py'
--- harvest/common/utils.py 2010-10-13 11:49:40 +0000
+++ harvest/common/utils.py 2010-12-08 08:22:15 +0000
@@ -1,12 +1,13 @@
-import subprocess
import datetime
+import email
+import errno
+import fcntl
import logging
import logging.handlers
-import email
-import fcntl
-import errno
import os
+import subprocess
+from bzrlib.branch import Branch
from django.conf import settings
def get_harvest_version(version_file, debug):
@@ -22,8 +23,7 @@
bzr_revno = f["revno"]
if debug:
- try:
- from bzrlib.branch import Branch
+ try:
branch = Branch.open_containing('.')[0]
bzr_revno = branch.revno()
except:
@@ -41,7 +41,6 @@
if debug:
try:
- from bzrlib.branch import Branch
branch = Branch.open_containing('.')[0]
version_str = "Revision %s" % branch.revno()
except:
=== modified file 'harvest/common/views.py'
--- harvest/common/views.py 2010-10-21 08:47:37 +0000
+++ harvest/common/views.py 2010-12-08 08:22:15 +0000
@@ -1,12 +1,14 @@
+from django.contrib.auth import logout
+from django.contrib.auth.models import User
+from django.db.models import F
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
-from django.contrib.auth import logout
-from django.contrib.auth.models import User
-from django.db.models import F
+
+from opportunities.models import SourcePackage, OpportunityList, Opportunity, Note
def index(request):
- from opportunities.models import SourcePackage, OpportunityList, Opportunity, Note
+
context = {
'pageSection': 'home',
'users': User.objects.count(),
=== modified file 'harvest/filters/containers.py'
--- harvest/filters/containers.py 2010-07-16 05:21:21 +0000
+++ harvest/filters/containers.py 2010-12-08 08:22:15 +0000
@@ -1,5 +1,5 @@
+from harvest.common.ordereddict import OrderedDict #while we wait for Python 2.7 :)
from harvest.common.url_tools import update_url_with_parameters
-from harvest.common.ordereddict import OrderedDict #while we wait for Python 2.7 :)
class FilterContainer(object): #abstract
"""
=== modified file 'harvest/filters/filters.py'
--- harvest/filters/filters.py 2010-08-05 14:36:14 +0000
+++ harvest/filters/filters.py 2010-12-08 08:22:15 +0000
@@ -1,8 +1,8 @@
#FIXME: The order that items are rendered in ChoiceFilter and FilterGroup needs to be as specified in the constructor. Currently, we are not in control of the order.
#TODO: adjust Filter.render() methods for custom template tags and use django.template.Template
+from django.utils.safestring import mark_safe
from containers import FilterContainer, FilterSystem
-from django.utils.safestring import mark_safe
class Filter(object): #abstract, extend in application
"""
=== modified file 'harvest/manage.py'
--- harvest/manage.py 2009-08-25 14:33:58 +0000
+++ harvest/manage.py 2010-12-08 08:22:15 +0000
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+
from django.core.management import execute_manager
+
try:
import settings # Assumed to be in the same directory.
except ImportError:
=== modified file 'harvest/opportunities/filters.py'
--- harvest/opportunities/filters.py 2010-09-03 12:29:02 +0000
+++ harvest/opportunities/filters.py 2010-12-08 08:22:15 +0000
@@ -1,6 +1,7 @@
+from django.utils.translation import ugettext as _
+
+from harvest.common.ordereddict import OrderedDict
from harvest.filters import filters, containers
-from harvest.common.ordereddict import OrderedDict
-from django.utils.translation import ugettext as _
import models
class PkgNameFilter(filters.EditFilter):
=== modified file 'harvest/opportunities/forms.py'
--- harvest/opportunities/forms.py 2010-08-16 18:57:42 +0000
+++ harvest/opportunities/forms.py 2010-12-08 08:22:15 +0000
@@ -1,6 +1,7 @@
from django import forms
+from django.utils.translation import ugettext as _
+
from models import Opportunity
-from django.utils.translation import ugettext as _
class OpportunityForm(forms.ModelForm):
new_note = forms.CharField(label=_("Enter a new note"),
=== modified file 'harvest/opportunities/management/commands/import-translations.py'
--- harvest/opportunities/management/commands/import-translations.py 2010-10-08 08:07:25 +0000
+++ harvest/opportunities/management/commands/import-translations.py 2010-12-08 08:22:15 +0000
@@ -1,14 +1,13 @@
#!/usr/bin/python
-from django.core.management.base import LabelCommand
-
+import os
+import re
import subprocess
+import sys
import tempfile
-import sys
-import os
-import re
from django.conf import settings
+from django.core.management.base import LabelCommand
try:
APP_NAME = settings.LP_PROJECT_NAME
=== modified file 'harvest/opportunities/management/commands/init-harvest.py'
--- harvest/opportunities/management/commands/init-harvest.py 2010-02-22 13:58:52 +0000
+++ harvest/opportunities/management/commands/init-harvest.py 2010-12-08 08:22:15 +0000
@@ -1,9 +1,8 @@
#!/usr/bin/python
+import subprocess
from django.core.management.base import NoArgsCommand
-import subprocess
-
class Command(NoArgsCommand):
help = "Make sure Harvest is set up properly."
=== modified file 'harvest/opportunities/management/commands/release.py'
--- harvest/opportunities/management/commands/release.py 2010-07-14 16:27:28 +0000
+++ harvest/opportunities/management/commands/release.py 2010-12-08 08:22:15 +0000
@@ -1,11 +1,11 @@
#!/usr/bin/python
-from django.core.management.base import BaseCommand, CommandError
-from django.conf import settings
-
+import os
import subprocess
import sys
-import os
+
+from django.conf import settings
+from django.core.management.base import BaseCommand, CommandError
def write_version_strings(version, version_name = ''):
try:
=== modified file 'harvest/opportunities/management/commands/update-template.py'
--- harvest/opportunities/management/commands/update-template.py 2010-10-08 08:07:25 +0000
+++ harvest/opportunities/management/commands/update-template.py 2010-12-08 08:22:15 +0000
@@ -1,11 +1,10 @@
#!/usr/bin/python
-from django.core.management.base import NoArgsCommand
-
+import os
import subprocess
-import os
from django.conf import settings
+from django.core.management.base import NoArgsCommand
try:
APP_NAME = settings.PROJECT_NAME
=== modified file 'harvest/opportunities/management/commands/update.py'
--- harvest/opportunities/management/commands/update.py 2010-10-07 15:36:29 +0000
+++ harvest/opportunities/management/commands/update.py 2010-12-08 08:22:15 +0000
@@ -1,11 +1,11 @@
#!/usr/bin/python
+import datetime
+
from django.core.management.base import NoArgsCommand
from common.utils import run_job
-import datetime
-
class Command(NoArgsCommand):
help = "Update everything."
=== modified file 'harvest/opportunities/management/commands/updatelists.py'
--- harvest/opportunities/management/commands/updatelists.py 2010-12-01 15:30:00 +0000
+++ harvest/opportunities/management/commands/updatelists.py 2010-12-08 08:22:15 +0000
@@ -1,17 +1,16 @@
#!/usr/bin/python
+import os
+import sys
+
+from django.conf import settings
from django.core.management.base import NoArgsCommand
-from django.conf import settings
from django.db import transaction
from common import opportunity_lists
+from common.utils import instantiate_logger
from opportunities.models import OpportunityList
-from common.utils import instantiate_logger
-
-import sys
-import os
-
class Command(NoArgsCommand):
help = "Pull opportunity lists and update them in the DB."
=== modified file 'harvest/opportunities/management/commands/updateopportunities.py'
--- harvest/opportunities/management/commands/updateopportunities.py 2010-11-16 12:10:27 +0000
+++ harvest/opportunities/management/commands/updateopportunities.py 2010-12-08 08:22:15 +0000
@@ -1,16 +1,16 @@
#!/usr/bin/python
+import os
+import sys
+
+from django.conf import settings
from django.core.management.base import NoArgsCommand
from django.db import transaction
-from django.conf import settings
from common import opportunity_lists
from common.utils import instantiate_logger
from opportunities import models
-import sys
-import os
-
class Command(NoArgsCommand):
help = "Pull opportunity lists and update them in the DB."
=== modified file 'harvest/opportunities/management/commands/updatepackagesets.py'
--- harvest/opportunities/management/commands/updatepackagesets.py 2010-10-07 15:37:45 +0000
+++ harvest/opportunities/management/commands/updatepackagesets.py 2010-12-08 08:22:15 +0000
@@ -1,14 +1,14 @@
#!/usr/bin/python
+import os
+import sys
+
from django.core.management.base import NoArgsCommand
from common import launchpad
from common.utils import instantiate_logger
from opportunities.models import SourcePackage, PackageSet
-import sys
-import os
-
class Command(NoArgsCommand):
help = "Pull packageset information from Launchpad."
=== modified file 'harvest/opportunities/models.py'
--- harvest/opportunities/models.py 2010-09-03 12:17:51 +0000
+++ harvest/opportunities/models.py 2010-12-08 08:22:15 +0000
@@ -1,8 +1,8 @@
+import datetime
+
+from django.contrib.auth.models import User
from django.db import models
from django.utils.translation import ugettext_lazy as _
-from django.contrib.auth.models import User
-
-import datetime
PACKAGE_GREEN_THRESHOLD = 5
PACKAGE_RED_THRESHOLD = 20
=== modified file 'harvest/opportunities/views.py'
--- harvest/opportunities/views.py 2010-10-21 08:47:37 +0000
+++ harvest/opportunities/views.py 2010-12-08 08:22:15 +0000
@@ -1,16 +1,15 @@
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
-from django.utils.translation import ugettext as _
+from django.db.models import F
+from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render_to_response as render
-from django.http import HttpResponseRedirect
-from django.db.models import F
from django.template import RequestContext
+from django.utils.translation import ugettext as _
+from filters import HarvestFilters
+import forms
import models
-import forms
-
-from filters import HarvestFilters
from wrappers import PackageWrapper, PackageListWrapper
def _create_packages_list(request, filters_pkg, filters_opp):
=== modified file 'harvest/services/__init__.py'
--- harvest/services/__init__.py 2010-08-23 14:15:29 +0000
+++ harvest/services/__init__.py 2010-12-08 08:22:15 +0000
@@ -3,12 +3,13 @@
# License: http://bitbucket.org/oct09/main/src/tip/COPYING
# Project: http://bitbucket.org/oct09/main/wiki/Home
+import decimal
+import re
+
from django.db.models import Model
+from django.forms.fields import EMPTY_VALUES
from django.http import HttpResponse
-from django.forms.fields import EMPTY_VALUES
from django.utils import simplejson
-import re
-import decimal
CHUNK_SIZE = 500
=== modified file 'harvest/services/views.py'
--- harvest/services/views.py 2010-08-23 14:15:29 +0000
+++ harvest/services/views.py 2010-12-08 08:22:15 +0000
@@ -1,6 +1,6 @@
+from django.contrib.auth.models import User
+
from opportunities.models import PackageSet, SourcePackage, OpportunityList, Opportunity, Note, ActionLogEntry
-from django.contrib.auth.models import User
-
from services import model_service
def user_service(request, url):
=== modified file 'harvest/settings.py'
--- harvest/settings.py 2010-10-15 11:54:34 +0000
+++ harvest/settings.py 2010-12-08 08:22:15 +0000
@@ -1,5 +1,19 @@
import logging
import os
+
+try:
+ import debug_toolbar
+ toolbar_available = True
+except ImportError:
+ toolbar_available = False
+
+try:
+ from local_settings import *
+except ImportError:
+ logging.warning("No local_settings.py were found. See INSTALL for instructions.")
+
+from common import utils
+
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
LOCALE_PATH = os.path.join(PROJECT_PATH, "locale")
DATA_PATH = os.path.join(PROJECT_PATH, "data")
@@ -14,12 +28,6 @@
INTERNAL_IPS = ('127.0.0.1',) #for testing
LOG_LEVEL = logging.ERROR
-try:
- import debug_toolbar
- toolbar_available = True
-except ImportError:
- toolbar_available = False
-
ADMINS = ('Daniel Holbach', 'daniel.holbach@xxxxxxxxxx')
MANAGERS = ADMINS
@@ -144,17 +152,9 @@
LOGIN_REDIRECT_URL = '/'
-import logging
-try:
- from local_settings import *
-except ImportError:
- logging.warning("No local_settings.py were found. See INSTALL for instructions.")
-
-
#local_settings.py can change the value of DEBUG, so we should only access it now
TEMPLATE_DEBUG = DEBUG
-from common import utils
VERSION_STRING = utils.get_harvest_version(
os.path.join(PROJECT_PATH, "version"),
DEBUG)
=== modified file 'harvest/urls.py'
--- harvest/urls.py 2010-10-04 14:44:01 +0000
+++ harvest/urls.py 2010-12-08 08:22:15 +0000
@@ -1,5 +1,5 @@
+from django.conf import settings
from django.conf.urls.defaults import *
-from django.conf import settings
from django.contrib import admin
admin.autodiscover()