Exemplo n.º 1
0
 def __init__(self):
     if os.path.isfile(filepather.relative_file_path(
             __file__, DB_FILE_NAME)):
         self.open()
     else:
         self.open()
         self.create_tables()
Exemplo n.º 2
0
 def test_splitting(self):
     bot = GGGGobblerBot(None, None)
     path = filepather.relative_file_path(__file__, os.path.join('testdata', 'longpost.txt'))
     with open(path) as md:
         staffposts = [StaffPost('abcdef', '123456', 'Bex', md.read(), 'date-test')]
         posts = bot.create_divided_comments(staffposts)
         self.assertEqual(len(posts), 7)
Exemplo n.º 3
0
 def load_values_v2(self, data_name):
     path = filepather.relative_file_path(__file__, os.path.join("testdata", "convert"))
     with open(os.path.join(path, data_name + "_input.html"), 'r') as f:
         # cut off the trailing \n
         html = f.read()[:-1]
     with open(os.path.join(path, data_name + "_output.md"), 'r') as f:
         expected_output = f.read()[:-1]
     return html, expected_output
Exemplo n.º 4
0
def prepare():
    logger = logging.getLogger(settings.LOGGER_NAME)
    fh = logging.FileHandler(
        filepather.relative_file_path(__file__, 'GGGGobblerVomit.log'))
    fmt = logging.Formatter('[%(levelname)s] [%(asctime)s]: %(message)s')
    fh.setFormatter(fmt)
    logger.addHandler(fh)
    logger.setLevel(logging.INFO)
    if not settings.LOGGING_ON:
        logging.disable(logging.CRITICAL)
Exemplo n.º 5
0
 def load_md(self, data_name):
     path = filepather.relative_file_path(
         __file__, os.path.join("testdata", "markdown"))
     with open(os.path.join(path, data_name + ".md"), 'r') as f:
         # cut off trailing \n
         file_contents = f.read()
         if file_contents[-1] != "\n":
             raise TestDataFileFormatException(
                 "Test data files should contain the tested text data following by an extraneous newline character"
             )
         return file_contents[:-1]
Exemplo n.º 6
0
 def open(self):
     self.db = sqlite3.connect(
         filepather.relative_file_path(__file__, DB_FILE_NAME))
Exemplo n.º 7
0
def read_ini():
    cfg = configparser.ConfigParser()
    cfg.read(filepather.relative_file_path(__file__, 'oauth.ini'))
    return cfg
Exemplo n.º 8
0
def _get_filename():
    return filepather.relative_file_path(__file__, os.path.join(os.pardir, FILENAME))