Esempio n. 1
0
def main():
    args = get_args()
    filepath = args.dir

    if args.type.startswith('.'):
        filetype = args.type
    else:
        filetype = '.' + args.type

    if args.fileoutname:
        outfilename = args.fileoutname + filetype
    else:
        outfilename = '--combined' + filetype

    # handle output directory cases
    if args.default:
        # import the path from config
        config_dir = get_json_config()['directories']
        rootdir = config_dir['bookmarksRootDir']
        combined_dir = config_dir['combinedFiles']
        if combined_dir == '':
            outfilepath = os.path.join(rootdir, outfilename)
        else:
            create_dir(os.path.join(rootdir, combined_dir))
            outfilepath = os.path.join(rootdir, combined_dir, outfilename)
    elif args.outdir:
        create_dir(args.outdir)
        outfilepath = os.path.join(args.outdir, outfilename)
    else:
        outfilepath = os.path.join(filepath, outfilename)

    # print(filepath, filetype, outfilename, outfilepath, args.default, args.outdir)#debug

    file_generator = create_file_iterator(filepath, filetype, outfilename)

    combine_files(outfilepath, file_generator, filepath)
Esempio n. 2
0
def main():
    description_str = '''Description:
    This script finds and replaces or removes certain html tags.
    It can be ran after
    - exporting an html file from Evernote
    - "clearning" html (I used https://html-cleaner.com/)'''

    args = get_args(description_str, {
        "flag": "html_file",
        "help": "evernote html file"
    }, {
        "flag": "-o",
        "help": "full output file path and name"
    })

    html_file = args.html_file
    output_location = args.o
    if not output_location:
        output_filename = 'evernote_output.html'
        config = get_json_config()
        outputlocation = os.path.join(
            config['directories']['bookmarksRootDir'], output_filename)

    create_file(outputlocation, 'w', html_file, get_replaced_line)
Esempio n. 3
0
import os
import sys
import re
import shutil

# Local modules:
from chr_path import getChromeJSON
from markdown_formatter import markdownFormatMap

# this import only works if you're in this directory
sys.path.insert(0, '../utils')
import date_append as DA
from file_utils import FileUtils
from get_config import get_json_config

config = get_json_config()

fileUtils = FileUtils()


class MarkdownCreator:
    def __init__(self):
        self.md_output = ''

    def deleter(self, f_str):
        '''deletes type, url in f_str
        '''
        return f_str\
            .replace('"type": "url",', '')

    def replacer(self, f_str):
Esempio n. 4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import shutil
import sys
# from chr_config import directories

# this import only works if you're in this directory
from get_config import get_json_config

directories = get_json_config()['directories']
'''
Calling shutil.move(source, destination) will move the file or folder at the path source to the path destination and will return a string of the absolute path of the new location.

If destination points to a folder, the source file gets moved into destination and keeps its current filename. For example, enter the following into the interactive shell:
'''


class FileUtils:
    # def __init__(self, input_file_path):
    #   self.input_file_path = input_file_path

    def fileExists(self, filePath):
        if os.path.exists(filePath):
            raise OSError(filePath + ' file exists.')

    def join_path(self, top_dir, root_dir=None):
        if not root_dir:
            root_dir = directories['bookmarksRootDir']
        return os.path.join(root_dir, top_dir)