Esempio n. 1
0
#!/usr/bin/env python2
# Author: Vsevolod Oparin, 2015

import re
import os.path
import argparse

import include.pyperclip  as        pyperclip
from   include.linkpool   import    LinkPool
from   include.settings   import    Settings
from   include.convertor  import    Convertor

default_directory   = __DEFAULT_SETTINGS__
pool_name           = "links"
default_setfile     = os.path.join(default_directory, "default.json")
settings            = Settings(default_setfile)

parser = argparse.ArgumentParser(description='Convert Markdown + LaTeX to habrahabr\'s format.')
parser.add_argument('infile', metavar='INFILE', nargs=1,
                   help='Name of input file')
parser.add_argument("-o", "--outfile", help = "Name of output file")
parser.add_argument("-c", "--clipboard", action='store_true', help = "Copy result to clipboard")
args = vars(parser.parse_args())


inname = args["infile"][0]
markdown = ""
if inname == "clipboard":
    args["clipboard"] = True
    if not os.path.isdir(default_directory):
        os.mkdir(default_directory)
Esempio n. 2
0
import os
import subprocess
import platform
import argparse

from   include.settings   import    Settings

parser = argparse.ArgumentParser(description='Init script.')
parser.add_argument("-l", "--link", action='store_true', help = "make symbolic link /usr/bin/poster")
args = vars(parser.parse_args())

default = "default.json"
poster  = "poster.py"
link    = "/usr/bin/poster"
settings = Settings(default)

place = "__DEFAULT_SETTINGS__"
path = os.path.dirname(os.path.abspath(default)).replace("\\", "\\\\")
with open("poster.py", "r") as f:
    code = f.read()
code = code.replace(place, "\"{0}\"".format(path))
with open("poster.py", "w") as f:
    f.write(code)

if os.name == 'nt' or platform.system() == 'Windows':
        settings.set_encoding('cp1251')

if args["link"]:
    print "Asked"
    if os.name != 'nt' and platform.system() != 'Windows':