Just fixed a few bugs
This commit is contained in:
parent
9bb58ca779
commit
9137347acb
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
#Copyright 2010 Chaz Littlejohn
|
#Copyright 2010 Chaz Littlejohn
|
||||||
|
@ -28,18 +28,21 @@ import Configuration
|
||||||
import Database
|
import Database
|
||||||
|
|
||||||
__ARCHIVE_PRE_HEADER_REGEX='^Hand #(\d+)\s*$|\*{20}\s#\s\d+\s\*+\s+'
|
__ARCHIVE_PRE_HEADER_REGEX='^Hand #(\d+)\s*$|\*{20}\s#\s\d+\s\*+\s+'
|
||||||
re_SplitArchive = re.compile(__ARCHIVE_PRE_HEADER_REGEX)
|
re_SplitArchive = re.compile(__ARCHIVE_PRE_HEADER_REGEX, re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
class IdentifySite:
|
class IdentifySite:
|
||||||
def __init__(self, config, in_path = '-'):
|
def __init__(self, config, in_path = '-'):
|
||||||
self.in_path = in_path
|
self.in_path = in_path
|
||||||
self.config = config
|
self.config = config
|
||||||
self.db = Database.Database(config)
|
self.db = Database.Database(self.config)
|
||||||
self.sitelist = {}
|
self.sitelist = {}
|
||||||
self.filelist = {}
|
self.filelist = {}
|
||||||
self.generateSiteList()
|
self.generateSiteList()
|
||||||
self.walkDirectory(self.in_path, self.sitelist)
|
if os.path.isdir(self.in_path):
|
||||||
|
self.walkDirectory(self.in_path, self.sitelist)
|
||||||
|
else:
|
||||||
|
self.idSite(self.in_path, self.sitelist)
|
||||||
|
|
||||||
def generateSiteList(self):
|
def generateSiteList(self):
|
||||||
"""Generates a ordered dictionary of site, filter and filter name for each site in hhcs"""
|
"""Generates a ordered dictionary of site, filter and filter name for each site in hhcs"""
|
||||||
|
@ -80,7 +83,7 @@ class IdentifySite:
|
||||||
for kodec in self.__listof(obj.codepage):
|
for kodec in self.__listof(obj.codepage):
|
||||||
try:
|
try:
|
||||||
in_fh = codecs.open(file, 'r', kodec)
|
in_fh = codecs.open(file, 'r', kodec)
|
||||||
whole_file = in_fh.read()
|
whole_file = in_fh.read(2000)
|
||||||
in_fh.close()
|
in_fh.close()
|
||||||
|
|
||||||
if info[2] in ('OnGame', 'Winamax'):
|
if info[2] in ('OnGame', 'Winamax'):
|
||||||
|
@ -94,7 +97,7 @@ class IdentifySite:
|
||||||
if re_SplitArchive.search(whole_file):
|
if re_SplitArchive.search(whole_file):
|
||||||
archive = True
|
archive = True
|
||||||
if m:
|
if m:
|
||||||
self.filelist[file] = [info[0]] + [info[1]] + [kodec] + [archive]
|
self.filelist[file] = [info[1]] + [kodec] + [archive]
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue
Block a user