mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-01-03 14:43:29 +01:00
Working towards python 2.7 & 3 cross compatibility.
This commit is contained in:
parent
7b97439fcd
commit
611e6cecf2
5 changed files with 9 additions and 8 deletions
|
|
@ -19,12 +19,11 @@ from __future__ import absolute_import
|
|||
import os, re, sys, glob, types
|
||||
from os.path import dirname, basename, normpath
|
||||
import logging
|
||||
from six.moves.urllib.parse import urlparse as up
|
||||
from six.moves.urllib.parse import urlparse
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
print(sys.path)
|
||||
from fanficfare.configurable import Configuration
|
||||
from .. import exceptions as exceptions
|
||||
|
||||
|
||||
|
|
@ -226,7 +225,7 @@ def getNormalStoryURL(url):
|
|||
def getNormalStoryURLSite(url):
|
||||
# print("getNormalStoryURLSite:%s"%url)
|
||||
if not getNormalStoryURL.__dummyconfig:
|
||||
getNormalStoryURL.__dummyconfig = Configuration(["test1.com"],"EPUB",lightweight=True)
|
||||
getNormalStoryURL.__dummyconfig = configurable.Configuration(["test1.com"],"EPUB",lightweight=True)
|
||||
# pulling up an adapter is pretty low over-head. If
|
||||
# it fails, it's a bad url.
|
||||
try:
|
||||
|
|
@ -300,7 +299,7 @@ def _get_class_for(url):
|
|||
if not "#post-" in fixedurl:
|
||||
fixedurl = re.sub(r"#.*$","",fixedurl)
|
||||
|
||||
parsedUrl = up.urlparse(fixedurl)
|
||||
parsedUrl = urlparse(fixedurl)
|
||||
domain = parsedUrl.netloc.lower()
|
||||
if( domain != parsedUrl.netloc ):
|
||||
fixedurl = fixedurl.replace(parsedUrl.netloc,domain)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
from .. import exceptions
|
||||
|
||||
from base_adapter import BaseSiteAdapter, makeDate
|
||||
from .base_adapter import BaseSiteAdapter, makeDate
|
||||
|
||||
class TestSiteAdapter(BaseSiteAdapter):
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ from datetime import datetime, timedelta
|
|||
from collections import defaultdict
|
||||
|
||||
import logging
|
||||
import urlparse as up
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from functools import partial
|
||||
import traceback
|
||||
import copy
|
||||
|
|
@ -125,7 +125,7 @@ class BaseSiteAdapter(Configurable):
|
|||
|
||||
def _setURL(self,url):
|
||||
self.url = url
|
||||
self.parsedUrl = up.urlparse(url)
|
||||
self.parsedUrl = urlparse(url)
|
||||
self.host = self.parsedUrl.netloc
|
||||
self.path = self.parsedUrl.path
|
||||
self.story.setMetadata('storyUrl',self.url,condremoveentities=False)
|
||||
|
|
@ -503,7 +503,7 @@ class BaseSiteAdapter(Configurable):
|
|||
if t.name=='script':
|
||||
t.extract()
|
||||
|
||||
except AttributeError, ae:
|
||||
except AttributeError as ae:
|
||||
if "%s"%ae != "'NoneType' object has no attribute 'next_element'":
|
||||
logger.error("Error parsing HTML, probably poor input HTML. %s"%ae)
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import cookielib as cl
|
|||
version="2.27.12"
|
||||
os.environ['CURRENT_VERSION_ID']=version
|
||||
|
||||
print("Python Version:%s"%sys.version)
|
||||
if sys.version_info < (2, 5) or sys.version_info > (3,0):
|
||||
print('This program requires Python 2.5 or newer. Python 3 is not supported.')
|
||||
sys.exit(1)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import http.cookiejar as cl
|
|||
|
||||
version="2.27.8"
|
||||
|
||||
print("Python Version:%s"%sys.version)
|
||||
if sys.version_info < (3,0):
|
||||
print('this program requires python 3 or newer.')
|
||||
sys.exit(1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue