flake8
[ckanext-ga-report.git] / ckanext / ga_report / command.py
blob:a/ckanext/ga_report/command.py -> blob:b/ckanext/ga_report/command.py
--- a/ckanext/ga_report/command.py
+++ b/ckanext/ga_report/command.py
@@ -1,7 +1,10 @@
 import logging
+import datetime
 
 from ckan.lib.cli import CkanCommand
-# No other CKAN imports allowed until _load_config is run, or logging is disabled
+# No other CKAN imports allowed until _load_config is run,
+# or logging is disabled
+
 
 class InitDB(CkanCommand):
     """Initialise the extension's database tables
@@ -46,9 +49,10 @@
         assuming it is correct.
         """
         from ga_auth import init_service
-        initialize_service('token.dat',
-                           self.args[0] if self.args
-                                        else 'credentials.json')
+        init_service('token.dat',
+                      self.args[0] if self.args
+                                   else 'credentials.json')
+
 
 class LoadAnalytics(CkanCommand):
     """Get data from Google Analytics API and save it
@@ -73,18 +77,20 @@
     def command(self):
         self._load_config()
 
-        from ga_auth import init_service
+        from download_analytics import DownloadAnalytics
+        from ga_auth import (init_service, get_profile_id)
+
         try:
             svc = init_service(self.args[0], None)
         except TypeError:
-            print 'Have you correctly run the getauthtoken task and specified the correct file here'
+            print ('Have you correctly run the getauthtoken task and '
+                   'specified the correct file here')
             return
 
-        from download_analytics import DownloadAnalytics
-        from ga_auth import get_profile_id
         downloader = DownloadAnalytics(svc, profile_id=get_profile_id(svc))
 
-        time_period = self.args[1] if self.args and len(self.args) > 1 else 'latest'
+        time_period = self.args[1] if self.args and len(self.args) > 1 \
+            else 'latest'
         if time_period == 'all':
             downloader.all_()
         elif time_period == 'latest':
@@ -93,4 +99,3 @@
             since_date = datetime.datetime.strptime(time_period, '%Y-%m-%d')
             downloader.since_date(since_date)
 
-