diff options
author | kinitrupti | 2016-10-24 12:32:11 +0530 |
---|---|---|
committer | kinitrupti | 2016-10-24 12:32:11 +0530 |
commit | eb3321f80def84e84329f213e21ef5ac94d4ccd6 (patch) | |
tree | 4c26ad501f9387e3d16c389603ae1432bd2c64fd | |
parent | 6da84d8c334e16ebea6597d8b83d51552935ed00 (diff) | |
download | Python-TBC-Interface-eb3321f80def84e84329f213e21ef5ac94d4ccd6.tar.gz Python-TBC-Interface-eb3321f80def84e84329f213e21ef5ac94d4ccd6.tar.bz2 Python-TBC-Interface-eb3321f80def84e84329f213e21ef5ac94d4ccd6.zip |
upgraded to python3
-rw-r--r-- | PythonTBC/settings.py | 55 | ||||
-rw-r--r-- | PythonTBC/urls.py | 2 | ||||
-rw-r--r-- | commentingapp/commenting_new.py | 6 | ||||
-rw-r--r-- | commentingapp/models.py | 5 | ||||
-rw-r--r-- | comments/admin.py | 2 | ||||
-rw-r--r-- | scripts/crawler/tbc_web_crawler/spiders/tbc_spider.py | 2 | ||||
-rw-r--r-- | scripts/database_updater.py | 4 | ||||
-rw-r--r-- | scripts/split_json.py | 8 | ||||
-rw-r--r-- | tbc/admin.py | 2 | ||||
-rw-r--r-- | tbc/models.py | 14 | ||||
-rw-r--r-- | tbc/views.py | 8 | ||||
-rw-r--r-- | tbc_error_page/models.py | 4 |
12 files changed, 41 insertions, 71 deletions
diff --git a/PythonTBC/settings.py b/PythonTBC/settings.py index e73bc25..46131a9 100644 --- a/PythonTBC/settings.py +++ b/PythonTBC/settings.py @@ -1,10 +1,10 @@ # Django settings for PythonTBC project. from os.path import * -from local import * +from .local import * DEBUG = True -#TEMPLATE_DEBUG = DEBUG +TEMPLATE_DEBUG = DEBUG ADMINS = ( @@ -94,11 +94,11 @@ STATICFILES_FINDERS = ( SECRET_KEY = 'a8zm$)bj&k9p2$1*biby#mo5fga#8$sr4&cmz%h=vum-xkbkme' # List of callables that know how to import templates from various sources. -#TEMPLATE_LOADERS = ( -# 'django.template.loaders.filesystem.Loader', -# 'django.template.loaders.app_directories.Loader', -# 'django.template.loaders.eggs.Loader', -#) +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + #'django.template.loaders.eggs.Loader', +) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', @@ -115,15 +115,15 @@ ROOT_URLCONF = 'PythonTBC.urls' # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'PythonTBC.wsgi.application' -#TEMPLATE_DIRS = ( +TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. -# join(PROJDIR, '../tbc/templates'), -# join(PROJDIR, '../tbc/static/uploads'), -# join(PROJDIR, '../comments/templates'), -# LOCAL_template_dirs, -#) + join(PROJDIR, '../tbc/templates'), + join(PROJDIR, '../tbc/static/uploads'), + join(PROJDIR, '../comments/templates'), + LOCAL_template_dirs, +) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', @@ -145,35 +145,6 @@ INSTALLED_APPS = ( 'taggit_templatetags2', ) -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [ - 'join(PROJDIR, "../tbc/templates")', - 'join(PROJDIR, "../tbc/static/uploads")', - 'join(PROJDIR, "../comments/templates")', - 'LOCAL_template_dirs', -], - #'APP_DIRS': True, - - 'OPTIONS': { - 'debug': DEBUG, - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - 'loaders': [ - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - -], - }, - }, -] - - SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer' # A sample logging configuration. The only tangible logging diff --git a/PythonTBC/urls.py b/PythonTBC/urls.py index 473dad1..77d166a 100644 --- a/PythonTBC/urls.py +++ b/PythonTBC/urls.py @@ -6,7 +6,7 @@ import django.contrib.sitemaps.views from django.contrib import admin admin.autodiscover() -from sitemap import TbcBookSitemap +from .sitemap import TbcBookSitemap sitemaps = { 'book': TbcBookSitemap, } diff --git a/commentingapp/commenting_new.py b/commentingapp/commenting_new.py index 33f4923..77c0fc5 100644 --- a/commentingapp/commenting_new.py +++ b/commentingapp/commenting_new.py @@ -3,7 +3,7 @@ import requests import collections import os -from urlparse import urljoin +from urllib.parse import urljoin @@ -75,7 +75,7 @@ class DisqusCommenting(object): json_like_list = [] - for thread_id in self.counter.keys(): # Find a better way to do this + for thread_id in list(self.counter.keys()): # Find a better way to do this comment_list = [] payload = {"api_key": self.public_key, "thread": thread_id} thread_url = urljoin(self.base_disqus_url,self.api_version)+"/threads/list.json" @@ -103,4 +103,4 @@ if __name__ == "__main__": z = x.get_thread_ids() z1 = x.get_comments() - print z1 # this will print out a json like list of all the urls and the comments on each url + print(z1) # this will print out a json like list of all the urls and the comments on each url diff --git a/commentingapp/models.py b/commentingapp/models.py index 79e120e..66ae0a1 100644 --- a/commentingapp/models.py +++ b/commentingapp/models.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals from django.db import models from tbc.models import Chapters, Book from django.contrib.auth.models import User @@ -14,9 +13,9 @@ class Url (models.Model): url = models.URLField() def get_contributor_details(self, counter): - notebooks = [os.path.join(chapter_name.split("/")[-2], chapter_name.split('/')[-1]) for chapter_name in counter.keys()] + notebooks = [os.path.join(chapter_name.split("/")[-2], chapter_name.split('/')[-1]) for chapter_name in list(counter.keys())] contributor_list = [] - for notebook,url,number_of_comments in zip(notebooks, counter.keys(), counter.values()): + for notebook,url,number_of_comments in zip(notebooks, list(counter.keys()), list(counter.values())): contributor_dict = {} contributor_id = Book.objects.filter(Q(chapters__notebook = notebook)).values_list("contributor_id", flat = True) contributor = User.objects.filter(id = contributor_id[0]).values("email", "first_name", "last_name") diff --git a/comments/admin.py b/comments/admin.py index 6ac89ae..17f2113 100644 --- a/comments/admin.py +++ b/comments/admin.py @@ -1,4 +1,4 @@ -from models import * +from .models import * from django.contrib import admin admin.site.register(Comment) diff --git a/scripts/crawler/tbc_web_crawler/spiders/tbc_spider.py b/scripts/crawler/tbc_web_crawler/spiders/tbc_spider.py index 9688e70..befc63f 100644 --- a/scripts/crawler/tbc_web_crawler/spiders/tbc_spider.py +++ b/scripts/crawler/tbc_web_crawler/spiders/tbc_spider.py @@ -1,5 +1,5 @@ import scrapy -from items import TbcErrorItems, TbcBrokenItems +from .items import TbcErrorItems, TbcBrokenItems from scrapy.utils.response import get_base_url from scrapy.utils.url import urljoin_rfc from scrapy.http import Request diff --git a/scripts/database_updater.py b/scripts/database_updater.py index 71813ea..6bbb1f6 100644 --- a/scripts/database_updater.py +++ b/scripts/database_updater.py @@ -74,5 +74,5 @@ if __name__ == '__main__': b = a.fetch_comments_from_script() c = a.add_comments_to_db() #This should always be before delete_redundant_comments d = a.delete_redundant_comments() #This should always be after add_comments_to_db - print c - print d + print (c) + print (d) diff --git a/scripts/split_json.py b/scripts/split_json.py index baa0b90..a6905db 100644 --- a/scripts/split_json.py +++ b/scripts/split_json.py @@ -1,4 +1,4 @@ -import cPickle +import pickle import json from os.path import dirname, abspath,join try: @@ -7,14 +7,14 @@ try: json_dump.close() a = [saved_data for saved_data in json_data if str(saved_data).startswith("{u'ch")] with open(join(dirname(abspath(dirname(__file__))),'tbc_error_page/error.pickle'), "w+") as error_json: - cPickle.dump(a, error_json) + pickle.dump(a, error_json) error_json.close() b = [saved_data for saved_data in json_data if str(saved_data).startswith("{u'br")] with open(join(dirname(abspath(dirname(__file__))),'tbc_error_page/broken.pickle'), "w+") as broken_json: - cPickle.dump(b, broken_json) + pickle.dump(b, broken_json) broken_json.close() except ValueError: - print "Couldn't find file" + print("Couldn't find file") diff --git a/tbc/admin.py b/tbc/admin.py index 30b5b34..4707d33 100644 --- a/tbc/admin.py +++ b/tbc/admin.py @@ -1,4 +1,4 @@ -from models import * +from .models import * from django.contrib import admin admin.site.register(Profile) diff --git a/tbc/models.py b/tbc/models.py index 8cb6c06..9b2adbf 100644 --- a/tbc/models.py +++ b/tbc/models.py @@ -2,7 +2,7 @@ from django.db import models from django.contrib.auth.models import User from PythonTBC import settings from django.contrib.admin.models import LogEntry -from local import sitemap_path +from .local import sitemap_path from taggit.managers import TaggableManager CATEGORY = (("fluid mechanics", "Fluid Mechanics"), @@ -177,12 +177,12 @@ class ActivityLog(LogEntry): class AicteBook(models.Model): title = models.TextField() - author = models.CharField(max_length=300L) - category = models.CharField(max_length=32L) - publisher_place = models.CharField(max_length=200L) - isbn = models.CharField(max_length=50L) - edition = models.CharField(max_length=15L) - year_of_pub = models.CharField(max_length=4L) + author = models.CharField(max_length=300) + category = models.CharField(max_length=32) + publisher_place = models.CharField(max_length=200) + isbn = models.CharField(max_length=50) + edition = models.CharField(max_length=15) + year_of_pub = models.CharField(max_length=4) proposed = models.BooleanField(default=False) def __unicode__(self): notebook = self.title or 'Book' diff --git a/tbc/views.py b/tbc/views.py index 9d8b7d4..3e9f0f5 100644 --- a/tbc/views.py +++ b/tbc/views.py @@ -8,12 +8,12 @@ from django.contrib.auth import authenticate, login, logout from django.contrib.admin.models import CHANGE from django.contrib.auth.decorators import login_required from django.template import RequestContext -from models import * +from .models import * from tbc.forms import * -import local +from . import local import os import zipfile -import StringIO +import io import smtplib import shutil import string @@ -1362,7 +1362,7 @@ def get_certificate(request, book_id=None): else: error = True add_log(user, book, CHANGE, err, proposal_id) - except Exception, e: + except Exception as e: error = True add_log(user, book, CHANGE, e, proposal_id) diff --git a/tbc_error_page/models.py b/tbc_error_page/models.py index 82c4da6..3f9b820 100644 --- a/tbc_error_page/models.py +++ b/tbc_error_page/models.py @@ -1,12 +1,12 @@ from django.db import models import os -import cPickle +import pickle def get_json_from_file(filename): path = os.path.join(os.path.dirname(os.path.abspath(__file__)), filename) if os.path.isfile(path): with open(path) as json_dump: - json_data =cPickle.load(json_dump) + json_data =pickle.load(json_dump) return json_data else: return False |