def mergeSources(srcdir, new_sources, old_sources): # The current mergeSources function provide only a raw copy of the sources in the # created project. # # TODO: implement the three way merge algorithm # shutil.rmtree(srcdir, True) copytree.copytree(os.path.join(new_sources, "bertos"), srcdir, ignore_list=const.IGNORE_LIST)
def rst2tex(in_path, out_path): options.mkdir_p(out_path) for file in glob.glob(os.path.join(in_path, '*')): if os.path.isdir(file): copytree(file, out_path) else: shutil.copy(file, out_path) base_dir = os.path.dirname(__file__) scipy_status = os.path.join(base_dir, '_static/status.sty') shutil.copy(scipy_status, out_path) scipy_style = os.path.join(base_dir, '_static/scipy.sty') shutil.copy(scipy_style, out_path) preamble = r'''\usepackage{scipy}''' # Add the LaTeX commands required by Pygments to do syntax highlighting pygments = None try: import pygments except ImportError: import warnings warnings.warn(RuntimeWarning('Could not import Pygments. ' 'Syntax highlighting will fail.')) if pygments: from pygments.formatters import LatexFormatter from writer.sphinx_highlight import SphinxStyle preamble += LatexFormatter(style=SphinxStyle).get_style_defs() settings = {'documentclass': 'IEEEtran', 'use_verbatim_when_possible': True, 'use_latex_citations': True, 'latex_preamble': preamble, 'documentoptions': 'letterpaper,compsoc,twoside', 'halt_level': 3, # 2: warn; 3: error; 4: severe } try: rst, = glob.glob(os.path.join(in_path, '*.rst')) except ValueError: raise RuntimeError("Found more than one input .rst--not sure which " "one to use.") content = header + open(rst, 'r').read() tex = dc.publish_string(source=content, writer=writer, settings_overrides=settings) tex_file = os.path.join(out_path, 'paper.tex') with open(tex_file, 'w') as f: f.write(tex)
def _writeCustomSrcFiles(self): origin = self.infos["PRESET_SRC_PATH"] # Files to be ignored (all project files, cfg dir, wizard mk file, all global ignored dirs) project_related_stuff = ( "cfg", "hw", self.infos["PRESET_NAME"] + ".mk", self.infos["PRESET_NAME"] + "_user.mk", "project.bertos", self.infos["PRESET_NAME"] + ".project", self.infos["PRESET_NAME"] + ".workspace", ) + const.IGNORE_LIST for element in os.listdir(origin): if element not in project_related_stuff: full_path = os.path.join(origin, element) if os.path.isdir(full_path): copytree.copytree(full_path, os.path.join(self.prjdir, element), ignore_list=const.IGNORE_LIST) else: shutil.copy(full_path, self.prjdir)
def _copySources(self, origin, destination): # If not in editing mode it copies all the bertos sources in the /bertos subdirectory of the project shutil.rmtree(destination, True) copytree.copytree(origin + "/bertos", destination, ignore_list=const.IGNORE_LIST)
# importing shutil module from copytree import copytree from copy3 import Filter # path = 'G:/' # source_path = path + 'shab33' # destination_path = path + 'G:/shab34' path = 'C:/temp/git_projects/' source_path = path + 'bbb' destination_path = path + 'aaa' from time_util import log log("Start Program") # Copy the content of source to destination copytree(source_path, destination_path) list = Filter.exts print(list)
def rst2tex(in_path, out_path): options.mkdir_p(out_path) for file in glob.glob(os.path.join(in_path, '*')): if os.path.isdir(file): copytree(file, out_path) else: shutil.copy(file, out_path) base_dir = os.path.dirname(__file__) scipy_status = os.path.join(base_dir, '_static/status.sty') shutil.copy(scipy_status, out_path) scipy_style = os.path.join(base_dir, '_static/scipy.sty') shutil.copy(scipy_style, out_path) preamble = r'''\usepackage{scipy}''' # Add the LaTeX commands required by Pygments to do syntax highlighting pygments = None try: import pygments except ImportError: import warnings warnings.warn( RuntimeWarning('Could not import Pygments. ' 'Syntax highlighting will fail.')) if pygments: from pygments.formatters import LatexFormatter from writer.sphinx_highlight import SphinxStyle preamble += LatexFormatter(style=SphinxStyle).get_style_defs() settings = { 'documentclass': 'wlpeerj', 'use_verbatim_when_possible': True, 'use_latex_citations': True, 'latex_preamble': preamble, 'documentoptions': 'fleqn,12pt', 'halt_level': 3, # 2: warn; 3: error; 4: severe } try: rst, = glob.glob(os.path.join(in_path, '*.rst')) except ValueError: raise RuntimeError("Found more than one input .rst--not sure which " "one to use.") content = header + open(rst, 'r').read() tex = dc.publish_string(source=content, writer=writer, settings_overrides=settings) tex = tex.replace('subsection{', 'section*{') # remove incorrect \labels texlines = tex.split('\n') texlines = filter(lambda x: not x.startswith(r' \label{'), texlines) tex = '\n'.join(texlines) tex_file = os.path.join(out_path, 'paper.tex') with open(tex_file, 'w') as f: f.write(tex)
def copy_dirs(source, target): copytree.copytree(source, target) return True
def main(args): is_release = "release" in args Path("../out/news").mkdir(parents=True, exist_ok=True) copytree("./news", "../out/news", ignore=ignore_patterns("*.md")) news_list = find_news() env = Environment( loader=PackageLoader("generate", "./templates"), autoescape=select_autoescape(["html", "xml"]), ) news_items = [ { "title": Markup(news.render_title_link("/" + news.path.strip("/") + "/")), "date": format_date(news.date), "path": news.path, } for news in news_list ] sitemap = Sitemap(BASE_URL) sitemap.add_url("/") sitemap.add_url("/news/") for news in news_list: render_template( env, "news.html", f"../out/{news.path.strip('/')}/index.html", release=is_release, meta_title=news.render_title(), meta_description=news.description, meta_canonical=f'{BASE_URL.rstrip("/")}/{news.path.strip("/")}/', content=Markup(news.html), date=format_date(news.date), other_news=[on for on in news_items if news.path != on["path"]][:3], ) sitemap.add_url(news.path) render_template( env, "news-index.html", "../out/news/index.html", release=is_release, news=news_items, meta_title="Новости", meta_description=( "Новости либертарианства и Либертарианской Партии России в Екатеринбурге и Свердловской области" ), meta_canonical=f'{BASE_URL.rstrip("/")}/news/', ) render_template( env, "home.html", "../out/index.html", release=is_release, news=news_items[:3], meta_description=( "Выступаем за свободную экономику, независимое местное самоуправление, " "суверенитет личности и против цензуры в интернете. Присоединяйся!" ), ) render_template(env, "sitemap.xml", "../out/sitemap.xml", urls=sitemap.urls) copytree("./static", "../out")
return activity_name,list(searchfs(src,filename))[0] def is_project(path): return PROPERTIES in os.listdir(path) if __name__=="__main__": loc = raw_input("Please enter the path to the eclipse project:\n") if not is_project(loc): pass classpath = path_join(loc,"." + CLASSPATH) manifest = path_join(loc,MANIFEST) src = path_join(loc,SRC) print "COPYING" copytree(ASSETS,loc) copytree(LIBS,loc) copytree(RES,loc) #print print "MERGING CLASSPATH" mergexml(path_join(RESOURCES,CLASSPATH),classpath,classpath) """ print mergexml(path_join(RESOURCES,CLASSPATH),classpath) print """ names = find_values(manifest,["application","activity"],"android:name") files = dict([find_activity(src,name) for name in names]) for name in files: