Example #1
0
    def __initialize(cls):

        # get the basic locations that the other locations build on
        script_dir = Directory.GetParent(__file__).FullName
        profile_dir = Environment.GetFolderPath(
           Environment.SpecialFolder.ApplicationData) + \
           r"\Comic Vine Scraper"

        # set the standard locations for settings files
        cls.SETTINGS_FILE = profile_dir + r'\settings.dat'
        cls.ADVANCED_FILE = profile_dir + r'\advanced.dat'
        cls.GEOMETRY_FILE = profile_dir + r'\geometry.dat'
        cls.SERIES_FILE = profile_dir + r'\series.dat'
        cls.LOCAL_CACHE_DIRECTORY = profile_dir + r'\localCache'
        cls.I18N_DEFAULTS_FILE = script_dir + r"\en.zip"

        # do a special trick to things run from within the IDE,
        # where certain files like 'en.zip' are in different locations
        ide_i18n_file = Directory.GetParent(
           Directory.GetParent( script_dir).FullName ).FullName + \
           r'\src\resources\languages\en.zip'
        if not File.Exists(cls.I18N_DEFAULTS_FILE) \
              and File.Exists( ide_i18n_file ):
            cls.I18N_DEFAULTS_FILE = ide_i18n_file

        # import settings from legacy location, if needed.
        # ensure profile directory exists.
        cls.__import_legacy_settings(script_dir, profile_dir)
        if not File.Exists(profile_dir):
            Directory.CreateDirectory(profile_dir)
Example #2
0
import clr
import re

clr.AddReference("System")
from System.IO import StreamReader, Directory
from System.Text import UTF8Encoding
# from System.Net import WebRequest
# from System.Text import Encoding

clr.AddReference("Ionic.Zip.dll")
from Ionic.Zip import ZipFile

clr.AddReference('System.Web.Extensions')
from System.Web.Script.Serialization import JavaScriptSerializer

_dir = Directory.GetParent(__file__).FullName
EHT_File = open(_dir + '\\EHT.json', 'r')
EHT = EHT_File.read()
EHT_File.close()
EHT = dict(JavaScriptSerializer().DeserializeObject(EHT))['dataset']

def EH_Scraper(books):
  for book in books:
    # ((cYo.Projects.ComicRack.Engine.ComicBook)book).FileLocation
    with ZipFile.Read(book.FileLocation) as zipfile:
      for i in zipfile.Entries:
        if re.search('info.txt', i.FileName):
          infoFile = i.FileName
          with StreamReader(zipfile[infoFile].OpenReader(), UTF8Encoding) as stream:
            contents = stream.ReadToEnd()
            info = parseInfoContent(contents)
Example #3
0
        else:
            # Spreadsheet exported as non-class
            workbook = context.get('workbook')
            if workbook is None:
                # Not a spreadsheet at all
                raise NoWorkbook(
                    "No workbook defined in this code. Are you sure it is a Resolver spreadsheet?"
                )

        return workbook
    finally:
        sys.path.remove(spreadsheetDirectory)


# Make sure the correct directory is in the path - or our imports will fail
mainDirectory = Directory.GetParent(
    Path.GetDirectoryName(Application.ExecutablePath))
if not mainDirectory in sys.path:
    sys.path.insert(0, mainDirectory)


class CreateHTMLForm(Form):
    """
    A form to create HTML files (web pages) from Resolver spreadsheets exported as code.
    
    You first choose the file to load and then the directory to put the output files in.
    """
    def __init__(self):
        self.Text = "Spreadsheet to HTML"
        self.Width = 220
        self.Height = 90
        self.FormBorderStyle = FormBorderStyle.Fixed3D