def __init__(self,folderpath):
     logger_cls = '%s.%s'%(Configuration_Handler.get('Logging', 'logger_instance_name'),self.__class__.__name__)
     self.__cp_law_files_directory = Configuration_Handler.get('DATA_FILES', 'copied_files_directory_name')
     self.__logger = logging.getLogger(logger_cls)
     self.__file_ext = Configuration_Handler.get('DATA_FILES', 'default_file_ext')
     self.__file_path = None
     self.__file_name = None
     self.__folder_files = None
     self.__folderpath = folderpath
Exemplo n.º 2
0
 def __init__(self, args=None):
     if args:
         self.__args = args
     self.__session = DBConnection().session
     self.__months_format = Configuration_Handler.get(
         'LAW_ATTRIBUTES_SETTINGS', 'months')
     self.__months__alternatives_format = Configuration_Handler.get(
         'LAW_ATTRIBUTES_SETTINGS', 'months_alternatives')
     logger_cls = '%s.%s' % (Configuration_Handler.get(
         'Logging', 'logger_instance_name'), self.__class__.__name__)
     self.__logger = logging.getLogger(logger_cls)
Exemplo n.º 3
0
        def __init__(self):
            Base = declarative_base()
            database_name = Configuration_Handler.get('DataDB', 'name')
            host = Configuration_Handler.get('DataDB', 'host')
            username = Configuration_Handler.get('DataDB', 'username')
            password = Configuration_Handler.get('DataDB', 'password')

            dbconnectionstring = 'mysql+pymysql://%s:%s@%s/%s?charset=utf8' % (
                username, password, host, database_name)
            engine = create_engine(dbconnectionstring)
            Base.metadata.create_all(engine)
            Session = sessionmaker(bind=engine)
            self.session = Session()
Exemplo n.º 4
0
 def __init__(self):
     # class attributes
     self.__folder_path = Configuration_Handler.get('DATA_FILES',
                                                    'folder_path')
     self.__logger = None
     self.__datareaderObj = DataFile(self.__folder_path)
     self.__lawObj = Law()
Exemplo n.º 5
0
    def __initiateLogger(self):

        # Logging configuration
        logger_cls = Configuration_Handler.get('Logging',
                                               'logger_instance_name')
        log_folder = Configuration_Handler.get('Logging', 'log_folder')

        logname = datetime.datetime.now().strftime("%Y-%m-%d")
        if not os.path.exists(log_folder):
            os.makedirs(log_folder)
        logname = '%s/%s' % (log_folder, logname)
        logging.basicConfig(
            filename=logname,
            filemode='a',
            format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
            datefmt='%H:%M:%S',
            level=logging.DEBUG)

        self.__logger = logging.getLogger(logger_cls)
Exemplo n.º 6
0
 def __fetchDataFolder(self):
     # Data files configuration
     processed_file_ext = Configuration_Handler.get('DATA_FILES',
                                                    'processed_file_ext')
     files = self.__datareaderObj.directory_files_list()
     for law_file_name in files:
         try:
             law_file_json = self.__datareaderObj.read(law_file_name)
             if self.__saveFileJson(law_file_name, law_file_json):
                 self.__datareaderObj.rename(processed_file_ext)
                 self.__datareaderObj.cp_modified_law_files(
                     law_file_name, self.__lawObj.get_attributes())
         except Exception as e:
             logger_string = 'File [%s] Error :[%s]' % (law_file_name,
                                                        str(e))
             self.__logger.info(logger_string)
from classes.config import Configuration_Handler
import datetime
from sqlalchemy import Column, ForeignKey, Integer, String, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
from sqlalchemy import Sequence

Base = declarative_base()
cnfHndl = Configuration_Handler()

database_name = cnfHndl.get('DataDB', 'name')
column_length = cnfHndl.get('DataDB', 'col_length')

class law_txt_files(Base):
	__tablename__ = 'law_txt_files'
	id = Column(Integer, primary_key=True)
	filename = Column(String(column_length, convert_unicode=True), nullable=False)
	status = Column(String(column_length, convert_unicode=True), nullable=False)
	created_at = Column(DateTime, default=datetime.datetime.utcnow)
Exemplo n.º 8
0
from classes.config import Configuration_Handler
from sqlalchemy import Column, ForeignKey, Integer, String, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
from sqlalchemy import Sequence
from sqlalchemy.sql import func
import datetime
import time

Base = declarative_base()
database_name = Configuration_Handler.get('DataDB', 'name')
column_length = Configuration_Handler.get('DataDB', 'col_length')

class Laws(Base):
	__tablename__ = 'laws'
	id = Column(Integer, primary_key=True)
	url = Column(String(column_length, convert_unicode=True), nullable=False)
	header = Column(String(column_length, convert_unicode=True), nullable=False)
	lawType = Column(String(column_length, convert_unicode=True), nullable=False)
	number = Column(Integer, nullable=False)
	title = Column(String(column_length, convert_unicode=True), nullable=False)
	year = Column(String(column_length, convert_unicode=True), nullable=False)
	legalStatus = Column(String(column_length, convert_unicode=True), nullable=False)
	noPages = Column(Integer, nullable=False)
	journal = Column(String(column_length, convert_unicode=True), nullable=False)
	journalNo = Column(Integer, nullable=False)
	issueType = Column(String(column_length, convert_unicode=True), nullable=False)
	issueDate = Column(DateTime(timezone=True), nullable=False)
	startDate = Column(DateTime(timezone=True), nullable=False)
	endDate = Column(DateTime(timezone=True))