From d938a8d6335b801e102159e82a6e0002dfaa1b1a Mon Sep 17 00:00:00 2001 From: Fahri Reza Date: Fri, 15 Oct 2021 09:00:07 +0700 Subject: [PATCH] forgot to commit, add _no_io_ and *_retcodes_ --- .gitignore | 1 + build.yml | 2 + etc/pylint.rc | 15 ++++++- etc/runner.json | 4 +- lib/fireh_runner | 2 +- pybuildtool/core/context.py | 2 +- pybuildtool/core/rule.py | 20 +++------ pybuildtool/core/task.py | 62 +++++++++++++++++++++++--- pybuildtool/misc/collections_utils.py | 2 +- pybuildtool/misc/python.py | 17 +++---- pybuildtool/misc/resource.py | 35 ++++++++++----- pybuildtool/misc/yaml_utils.py | 4 +- pybuildtool/tools/ansibleplay.py | 7 +-- pybuildtool/tools/clean-css.py | 2 +- pybuildtool/tools/concat.py | 11 ++++- pybuildtool/tools/cp.py | 7 +++ pybuildtool/tools/gzip.py | 2 +- pybuildtool/tools/handlebars.py | 2 +- pybuildtool/tools/jinja.py | 11 ++--- pybuildtool/tools/less.py | 2 +- pybuildtool/tools/metadata2fontface.py | 9 ++-- pybuildtool/tools/mustache.py | 4 +- pybuildtool/tools/node-sass.py | 2 +- pybuildtool/tools/nunjucks.py | 2 +- pybuildtool/tools/pylint.py | 3 ++ pybuildtool/tools/stylus.py | 2 +- pybuildtool/tools/ttf2eot.py | 2 +- pybuildtool/tools/ttf2svg.py | 2 +- pybuildtool/tools/ttf2woff.py | 4 +- pybuildtool/tools/uglify-js.py | 2 +- pybuildtool/tools/woff2svg.py | 2 +- pybuildtool/tools/woff2ttf.py | 2 +- setup.cfg | 2 +- setup.py | 7 +-- 34 files changed, 169 insertions(+), 86 deletions(-) diff --git a/.gitignore b/.gitignore index d4617fe..afb2116 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ /.virtualenv/ /requirements.txt /python_modules +/pybuildtool/.coverage # waf diff --git a/build.yml b/build.yml index 903afd6..f6a959e 100644 --- a/build.yml +++ b/build.yml @@ -35,6 +35,7 @@ pybuildtool: unittest: shell: options: + _noop_retcodes_: [5] command: ./run pybin coverage run --include=./* -m py.test rule_in: - "{_1}/pylint" @@ -48,6 +49,7 @@ pybuildtool: coverage: shell: options: + _noop_retcodes_: [1] command: ./run pybin coverage report -m --skip-covered rule_in: - "{_1}/unittest/shell" diff --git a/etc/pylint.rc b/etc/pylint.rc index 88d92d9..e726a94 100644 --- a/etc/pylint.rc +++ b/etc/pylint.rc @@ -139,7 +139,20 @@ disable=print-statement, deprecated-sys-function, exception-escape, comprehension-escape, - too-many-locals + too-many-locals, + duplicate-code, + missing-class-docstring, + missing-function-docstring, + missing-module-docstring, + too-many-arguments, + invalid-name, + protected-access, + consider-using-f-string, + too-many-branches, + too-many-statements, + too-few-public-methods, + too-many-instance-attributes, + too-many-ancestors # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/etc/runner.json b/etc/runner.json index 14d4cfc..0f42a3e 100644 --- a/etc/runner.json +++ b/etc/runner.json @@ -9,8 +9,8 @@ "lib.fireh_runner.setup_modules.python", "lib.fireh_runner.setup_modules.pybuildtool" ], - "python_version": "3.8", - "waf_version": "2.0.20", + "python_version": "3.9", + "waf_version": "2.0.22", "package_name": "PyBuildTool", "default_project": "pybuildtool", diff --git a/lib/fireh_runner b/lib/fireh_runner index 4e9ee7b..4a7084b 160000 --- a/lib/fireh_runner +++ b/lib/fireh_runner @@ -1 +1 @@ -Subproject commit 4e9ee7be2d1f9e0150d02d9bcb056bc16ca693d8 +Subproject commit 4a7084b63673e3b1a7ebdc2b38572ba7cda5402e diff --git a/pybuildtool/core/context.py b/pybuildtool/core/context.py index ab1914f..6dd2c58 100644 --- a/pybuildtool/core/context.py +++ b/pybuildtool/core/context.py @@ -7,7 +7,7 @@ class WatchContext(Context.Context): variant = '' def __init__(self, **kw): - super(WatchContext, self).__init__(**kw) + super().__init__(**kw) self.top_dir = kw.get('top_dir', Context.top_dir) self.out_dir = kw.get('out_dir', Context.out_dir) diff --git a/pybuildtool/core/rule.py b/pybuildtool/core/rule.py index afc98a1..1ae5147 100644 --- a/pybuildtool/core/rule.py +++ b/pybuildtool/core/rule.py @@ -1,8 +1,7 @@ from hashlib import md5 import os import re - -from ..misc.collections_utils import make_list +#- from ..misc.path import expand_resource @@ -26,9 +25,8 @@ def __init__(self, group, config, file_in, file_out, depend_in, extra_out): for fs in (self.file_in, self.depend_in): self._expand_input_wilcards(fs) - # normalize `replace_patterns`, must be a list - self.conf['replace_patterns'] = make_list( - self.conf.get('replace_patterns')) + # normalize `_replace_patterns_`, must be a list of list + self.conf.setdefault('_replace_patterns_', []) def _expand_input_wilcards(self, items): @@ -86,10 +84,8 @@ def files(self): if is_dir: for fi in self.file_in: fofi = fi - replace_patterns = self.conf.get('replace_patterns', False) - if replace_patterns: - for (pat, rep) in replace_patterns: - fofi = re.sub(pat, rep, fofi) + for (pat, rep) in self.conf['_replace_patterns_']: + fofi = re.sub(pat, rep, fofi) basedir = self.conf.get('_source_basedir_', False) if basedir: basedir = expand_resource(self.group, basedir) @@ -148,10 +144,8 @@ def rules(self): continue fofi = fi - replace_patterns = self.conf.get('replace_patterns', False) - if replace_patterns: - for (pat, rep) in replace_patterns: - fofi = re.sub(pat, rep, fofi) + for (pat, rep) in self.conf['_replace_patterns_']: + fofi = re.sub(pat, rep, fofi) # use basedir to produce file_out basedir = self.conf.get('_source_basedir_', False) if basedir: diff --git a/pybuildtool/core/task.py b/pybuildtool/core/task.py index d680e1d..acf1657 100644 --- a/pybuildtool/core/task.py +++ b/pybuildtool/core/task.py @@ -1,3 +1,41 @@ +""" +Base class for pybuildtools tools. + +Options: + + * _source_excluded_ : list, None + : Pretend source files (*_in values) don't exist. + + * _source_basedir_ : str, None + : Create files in output dir, relative path to source + : base directory. + + * _source_grouped_ : bool, None + : Don't create separate tasks for every input files, have + : them as input files of a single task. + : Actually I'm not so sure what this does, something like + : have them all as arguments to shell command? + + * _noop_retcodes_ : list, None + : If Task.perform() returns these, pretend nothing + : happened. + + * _success_retcodes_ : list, None + : If Task.perform() returns these, pretend as if it + : returns 0 or a success. + + * _replace_patterns_ : list, None + : If the output is a directory, you can rename the + : output files based on the source files. + : This is a list of list. + : The list elements consist of two items: python regex + : and replacement. + + * _no_io_ : bool, False + : This task doesn't need inputs or outputs. + : Only works if written in build.yml. + +""" import os from copy import deepcopy from time import time @@ -23,7 +61,7 @@ class Task(BaseTask): _id = None def __init__(self, group, config, *args, **kwargs): - super(Task, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._id = uuid4().hex # Task's configuration can be declared higher in the build tree, @@ -57,7 +95,7 @@ def prepare(self): pass - def prepare_args(self): + def prepare_args(self): # pylint:disable=no-self-use return [] @@ -90,13 +128,15 @@ def prepare_shadow_jutsu(self): self.file_out.append(path) - def finalize_shadow_jutsu(self): + def finalize_shadow_jutsu(self, create_only=False): for filename in self.token_out: + if create_only and os.path.exists(filename): + continue try: os.makedirs(os.path.dirname(filename)) except OSError: pass - with open(filename, 'w') as f: + with open(filename, 'w', encoding='utf-8') as f: f.write(str(time())) @@ -104,12 +144,20 @@ def run(self): self.prepare_shadow_jutsu() self.prepare() ret = self.perform() - if ret == 0: - self.finalize_shadow_jutsu() + + create_only = False + if ret in make_list(self.conf.get('_noop_retcodes_')): + create_only = True + ret = None + elif ret in make_list(self.conf.get('_success_retcodes_')): + ret = None + if not ret: + self.finalize_shadow_jutsu(create_only) return ret - def is_production(self): + @staticmethod + def is_production(): return os.environ.get('PROJECT_VARIANT_IS_PRODUCTION') == '1' diff --git a/pybuildtool/misc/collections_utils.py b/pybuildtool/misc/collections_utils.py index cc4974a..fde4adf 100644 --- a/pybuildtool/misc/collections_utils.py +++ b/pybuildtool/misc/collections_utils.py @@ -44,7 +44,7 @@ def data_merge(a, b): except TypeError as e: raise Exception( 'TypeError "%s" in key "%s" when merging "%s" into "%s"' %\ - (e, key, b, a)) + (e, key, b, a)) from e return a diff --git a/pybuildtool/misc/python.py b/pybuildtool/misc/python.py index 7befc21..607b4c6 100644 --- a/pybuildtool/misc/python.py +++ b/pybuildtool/misc/python.py @@ -1,15 +1,8 @@ -try: - from importlib.machinery import SourceFileLoader - from importlib.util import module_from_spec, spec_from_loader -except ImportError: - import imp - +from importlib.machinery import SourceFileLoader +from importlib.util import module_from_spec, spec_from_loader def load_module_from_filename(filename, name): - try: - spec = spec_from_loader(name, SourceFileLoader(name, filename)) - mod = module_from_spec(spec) - spec.loader.exec_module(mod) - except NameError: - mod = imp.load_source(name, filename) + spec = spec_from_loader(name, SourceFileLoader(name, filename)) + mod = module_from_spec(spec) + spec.loader.exec_module(mod) return mod diff --git a/pybuildtool/misc/resource.py b/pybuildtool/misc/resource.py index 807c21f..be6bcd3 100644 --- a/pybuildtool/misc/resource.py +++ b/pybuildtool/misc/resource.py @@ -1,8 +1,20 @@ +import hashlib +import mmap import os import re from ..core.group import Group from .collections_utils import make_list +def get_filehash(filename): + if not os.path.exists(filename): + return None + hasher = hashlib.sha1() + with open(filename, 'rb') as f: + with mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ) as mm: + hasher.update(mm) + return hasher.digest() + + def get_source_files(conf, bld): """Collect raw file inputs.""" groups = {} @@ -11,7 +23,8 @@ def get_source_files(conf, bld): def parse_group(group_name, config, level): groups['_%s' % level] = group_name - if group_is_leaf(config): + options = config.pop('options', {}) + if group_is_leaf(config, options): group_files = make_list(config.get('raw_file_in')) +\ make_list(config.get('raw_depend_in')) @@ -25,9 +38,6 @@ def parse_group(group_name, config, level): return for subgroup in config: - if subgroup == 'options': - continue - for f in parse_group(subgroup, config[subgroup], level + 1): yield f @@ -39,12 +49,13 @@ def parse_group(group_name, config, level): yield f -def group_is_leaf(group): +def group_is_leaf(group, options): """The lowests in the group tree are the tools.""" return any(x in group for x in ('file_in', 'raw_file_in', 'file_out', 'raw_file_out', 'depend_in', 'raw_depend_in', 'extra_out', - 'raw_extra_out', 'rule_in')) + 'raw_extra_out', 'rule_in'))\ + or options.get('_no_io_', False) def prepare_targets(conf, bld): @@ -100,7 +111,7 @@ def parse_group(group_name, config, level, parent_group): groups[g.get_name()] = g pattern = g.get_patterns() - if group_is_leaf(config): + if group_is_leaf(config, options): original_file_in = make_list(config.get('file_in')) file_in = list(_parse_input_listing(original_file_in, pattern)) _add_raw_files(make_list(config.get('raw_file_in')), file_in, @@ -129,12 +140,16 @@ def parse_group(group_name, config, level, parent_group): token_names = bld._token_names[rule_in] for f in token_names: depend_in.append(f) - except (KeyError, AttributeError) as e: + except (KeyError, AttributeError): print((parent_group.get_name(), group_name, dict(config), level)) - bld.fatal('rule "%s" not found in: %s' % (rule_in, - ', '.join(bld._token_names.keys()))) + if hasattr(bld, '_token_names'): + bld.fatal("rule '%s' not found in: %s" % (rule_in, + ', '.join(bld._token_names.keys()))) + else: + bld.fatal("rule '%s' not found" % rule_in +\ + ", does it have *_in or *_out?") g(file_in=file_in, file_out=file_out, depend_in=depend_in, extra_out=extra_out) diff --git a/pybuildtool/misc/yaml_utils.py b/pybuildtool/misc/yaml_utils.py index 79040b8..8e212e9 100644 --- a/pybuildtool/misc/yaml_utils.py +++ b/pybuildtool/misc/yaml_utils.py @@ -20,10 +20,10 @@ class OrderedDictYAMLLoader(yaml.Loader): def __init__(self, *args, **kwargs): yaml.Loader.__init__(self, *args, **kwargs) - self.add_constructor(u'tag:yaml.org,2002:map', + self.add_constructor('tag:yaml.org,2002:map', type(self).construct_yaml_map) - self.add_constructor(u'tag:yaml.org,2002:omap', + self.add_constructor('tag:yaml.org,2002:omap', type(self).construct_yaml_map) def construct_yaml_map(self, node): diff --git a/pybuildtool/tools/ansibleplay.py b/pybuildtool/tools/ansibleplay.py index 3bedc5d..ce50703 100644 --- a/pybuildtool/tools/ansibleplay.py +++ b/pybuildtool/tools/ansibleplay.py @@ -31,10 +31,11 @@ import os import sys import six +from waflib import Logs # pylint:disable=import-error from yaml import safe_load as yaml_load +#- from pybuildtool import BaseTask, expand_resource, make_list from pybuildtool.misc.python import load_module_from_filename -from waflib import Logs # pylint:disable=import-error tool_name = __name__ @@ -45,7 +46,7 @@ class Task(BaseTask): items = None def __init__(self, *args, **kwargs): - super(Task, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.context = {} self.items = [] @@ -108,7 +109,7 @@ def prepare(self): if yaml_file is None: self.bld.fatal('"context_yaml" for %s has invalid value' %\ tool_name.capitalize()) - with open(yaml_file, 'r') as f: + with open(yaml_file, 'r', encoding='utf-8') as f: self.context.update(yaml_load(f)) # Python context diff --git a/pybuildtool/tools/clean-css.py b/pybuildtool/tools/clean-css.py index 86f6647..cdbb482 100644 --- a/pybuildtool/tools/clean-css.py +++ b/pybuildtool/tools/clean-css.py @@ -39,7 +39,7 @@ class Task(BaseTask): conf = { - 'replace_patterns': ((r'\.css$', '.min.css'),), + '_replace_patterns_': ((r'\.css$', '.min.css'),), } name = tool_name diff --git a/pybuildtool/tools/concat.py b/pybuildtool/tools/concat.py index 899c45a..b8fc129 100644 --- a/pybuildtool/tools/concat.py +++ b/pybuildtool/tools/concat.py @@ -3,6 +3,7 @@ import os from shutil import copyfileobj from pybuildtool import BaseTask +from pybuildtool.misc.resource import get_filehash tool_name = __name__ @@ -10,6 +11,7 @@ class Task(BaseTask): conf = { '_source_grouped_': True, + '_noop_retcodes_': 666, } name = tool_name @@ -22,9 +24,14 @@ def perform(self): self.bld.fatal('cannot concat to a directory') try: + before_hash = get_filehash(self.file_out[0]) with open(self.file_out[0], 'wb') as dest: - for src in self.file_in: - copyfileobj(open(src, 'rb'), dest) + for src_name in self.file_in: + with open(src_name, 'rb') as src: + copyfileobj(src, dest) + + if before_hash == get_filehash(self.file_out[0]): + return 666 return 0 except OSError: return 1 diff --git a/pybuildtool/tools/cp.py b/pybuildtool/tools/cp.py index 9e4daf4..684bb74 100644 --- a/pybuildtool/tools/cp.py +++ b/pybuildtool/tools/cp.py @@ -2,11 +2,15 @@ """ from shutil import copyfile, Error from pybuildtool import BaseTask +from pybuildtool.misc.resource import get_filehash tool_name = __name__ class Task(BaseTask): + conf = { + '_noop_retcodes_': 666, + } name = tool_name def perform(self): @@ -19,6 +23,9 @@ def perform(self): tool_name.capitalize(), repr(self.file_out))) try: + source_hash = get_filehash(self.file_in[0]) + if source_hash and source_hash == get_filehash(self.file_out[0]): + return 666 copyfile(self.file_in[0], self.file_out[0]) return 0 except Error: diff --git a/pybuildtool/tools/gzip.py b/pybuildtool/tools/gzip.py index 95793db..93f0aab 100644 --- a/pybuildtool/tools/gzip.py +++ b/pybuildtool/tools/gzip.py @@ -13,7 +13,7 @@ class Task(BaseTask): conf = { - 'replace_patterns': ((r'$', '.gz'),), + '_replace_patterns_': ((r'$', '.gz'),), } name = tool_name diff --git a/pybuildtool/tools/handlebars.py b/pybuildtool/tools/handlebars.py index 5120263..6b2b3da 100644 --- a/pybuildtool/tools/handlebars.py +++ b/pybuildtool/tools/handlebars.py @@ -38,7 +38,7 @@ class Task(BaseTask): conf = { - 'replace_patterns': ((r'\.handlebars$', '.js'),), + '_replace_patterns_': ((r'\.handlebars$', '.js'),), } name = tool_name diff --git a/pybuildtool/tools/jinja.py b/pybuildtool/tools/jinja.py index 7bd6003..5667eb8 100644 --- a/pybuildtool/tools/jinja.py +++ b/pybuildtool/tools/jinja.py @@ -21,10 +21,7 @@ to install, run `pip install jinja2` """ -try: - from collections.abc import Mapping, Sequence -except ImportError: - from collections import Mapping, Sequence +from typing import Mapping, Sequence from json import load as json_load import os import sys @@ -73,7 +70,7 @@ def prepare(self): files = [x for x in (expand_resource(self.group, f) for f\ in files) if x] for json_file in files: - with open(json_file, 'r') as f: + with open(json_file, 'r', encoding='utf-8') as f: dict_merge(self.context, json_load(f)) # Yaml context @@ -82,7 +79,7 @@ def prepare(self): files = [x for x in (expand_resource(self.group, f) for f\ in files) if x] for yaml_file in files: - with open(yaml_file, 'r') as f: + with open(yaml_file, 'r', encoding='utf-8') as f: dict_merge(self.context, yaml_load(f)) # Python context @@ -123,6 +120,6 @@ def perform(self): template = env.get_template(template_name) rendered = template.render(self.context) for out in self.file_out: - with open(out, 'w') as f: + with open(out, 'w', encoding='utf-8') as f: f.write(rendered) return 0 diff --git a/pybuildtool/tools/less.py b/pybuildtool/tools/less.py index f669e13..3467d65 100644 --- a/pybuildtool/tools/less.py +++ b/pybuildtool/tools/less.py @@ -24,7 +24,7 @@ class Task(BaseTask): conf = { - 'replace_patterns': ((r'\.less$', '.css'),) + '_replace_patterns_': ((r'\.less$', '.css'),) } name = tool_name diff --git a/pybuildtool/tools/metadata2fontface.py b/pybuildtool/tools/metadata2fontface.py index a821c4a..8069e24 100644 --- a/pybuildtool/tools/metadata2fontface.py +++ b/pybuildtool/tools/metadata2fontface.py @@ -56,14 +56,14 @@ def perform(self): filename = self.file_in[0] if filename.endswith('.json'): - with open(self.file_in[0], 'r') as f: + with open(self.file_in[0], 'r', encoding='utf-8') as f: fonts = json.load(f)['fonts'] elif filename.endswith('.pb'): fonts = self._get_fonts_from_protobuf(filename) else: self.bld.fatal('Unknown file format: ' + filename) - with open(self.file_out[0], 'w') as f: + with open(self.file_out[0], 'w', encoding='utf-8') as f: for font in fonts: f.write('@font-face {\n') f.write(' font-family: "%s";\n' % font['name']) @@ -94,12 +94,13 @@ def perform(self): f.write(';\n}\n') - def _get_fonts_from_protobuf(self, filename): + @staticmethod + def _get_fonts_from_protobuf(filename): from google.protobuf import text_format # pylint:disable=import-error,no-name-in-module,import-outside-toplevel from pybuildtool.vendor.fonts_public_pb2 import FamilyProto # pylint:disable=import-outside-toplevel message = FamilyProto() - with open(filename) as f: + with open(filename, encoding='utf-8') as f: text_format.Merge(f.read(), message) for font in message.fonts: diff --git a/pybuildtool/tools/mustache.py b/pybuildtool/tools/mustache.py index 85b0fda..8ce2405 100644 --- a/pybuildtool/tools/mustache.py +++ b/pybuildtool/tools/mustache.py @@ -26,8 +26,8 @@ def perform(self): context = self.conf.get('context', {}) os.makedirs(os.path.dirname(self.file_out[0]), exist_ok=True) - with open(self.file_out[0], 'w') as fout: - with open(self.file_in[0], 'r') as fin: + with open(self.file_out[0], 'w', encoding='utf-8') as fout: + with open(self.file_in[0], 'r', encoding='utf-8') as fin: fout.write(render(fin.read(), dict(context))) return 0 diff --git a/pybuildtool/tools/node-sass.py b/pybuildtool/tools/node-sass.py index 6b78a87..ca268f7 100644 --- a/pybuildtool/tools/node-sass.py +++ b/pybuildtool/tools/node-sass.py @@ -70,7 +70,7 @@ class Task(BaseTask): name = tool_name conf = { - 'replace_patterns': ((r'\.scss$', '.css'),) + '_replace_patterns_': ((r'\.scss$', '.css'),) } workdir = None diff --git a/pybuildtool/tools/nunjucks.py b/pybuildtool/tools/nunjucks.py index 6de7269..9eccae6 100644 --- a/pybuildtool/tools/nunjucks.py +++ b/pybuildtool/tools/nunjucks.py @@ -34,7 +34,7 @@ class Task(BaseTask): conf = { - 'replace_patterns': ((r'\.html', '.js'),), + '_replace_patterns_': ((r'\.html', '.js'),), } name = tool_name diff --git a/pybuildtool/tools/pylint.py b/pybuildtool/tools/pylint.py index 3a3f1cc..67c96a1 100644 --- a/pybuildtool/tools/pylint.py +++ b/pybuildtool/tools/pylint.py @@ -23,6 +23,9 @@ class Task(BaseTask): + conf = { + '_noop_retcodes_': [4], + } name = tool_name workdir = None diff --git a/pybuildtool/tools/stylus.py b/pybuildtool/tools/stylus.py index ad7f36c..cce9a08 100644 --- a/pybuildtool/tools/stylus.py +++ b/pybuildtool/tools/stylus.py @@ -81,7 +81,7 @@ class Task(BaseTask): name = tool_name conf = { - 'replace_patterns': ((r'\.styl$', '.css'),) + '_replace_patterns_': ((r'\.styl$', '.css'),) } workdir = None diff --git a/pybuildtool/tools/ttf2eot.py b/pybuildtool/tools/ttf2eot.py index d903865..3c8f7d0 100644 --- a/pybuildtool/tools/ttf2eot.py +++ b/pybuildtool/tools/ttf2eot.py @@ -16,7 +16,7 @@ class Task(BaseTask): conf = { - 'replace_patterns': ((r'\.ttf$', '.eot'), (r'\.otf$', '.eot')) + '_replace_patterns_': ((r'\.ttf$', '.eot'), (r'\.otf$', '.eot')) } name = tool_name diff --git a/pybuildtool/tools/ttf2svg.py b/pybuildtool/tools/ttf2svg.py index 1a2d7de..e5d8305 100644 --- a/pybuildtool/tools/ttf2svg.py +++ b/pybuildtool/tools/ttf2svg.py @@ -15,7 +15,7 @@ class Task(BaseTask): conf = { - 'replace_patterns': ((r'\.ttf$', '.svg'), (r'\.otf$', '.svg')) + '_replace_patterns_': ((r'\.ttf$', '.svg'), (r'\.otf$', '.svg')) } name = tool_name diff --git a/pybuildtool/tools/ttf2woff.py b/pybuildtool/tools/ttf2woff.py index 4ccc1c5..bc8c1ba 100644 --- a/pybuildtool/tools/ttf2woff.py +++ b/pybuildtool/tools/ttf2woff.py @@ -16,7 +16,7 @@ class Task(BaseTask): conf = { - 'replace_patterns': ((r'\.ttf$', '.woff'), (r'\.otf$', '.woff')) + '_replace_patterns_': ((r'\.ttf$', '.woff'), (r'\.otf$', '.woff')) } name = tool_name @@ -38,7 +38,7 @@ def perform(self): # success exit code move_executable = self.env['MV_BIN'] converted_file = self.file_in[0] - for (pat, rep) in self.conf['replace_patterns']: + for (pat, rep) in self.conf['_replace_patterns_']: converted_file = re.sub(pat, rep, converted_file) ret = self.exec_command( '{exe} {in_} {out}'.format( diff --git a/pybuildtool/tools/uglify-js.py b/pybuildtool/tools/uglify-js.py index 628040d..f5139a5 100644 --- a/pybuildtool/tools/uglify-js.py +++ b/pybuildtool/tools/uglify-js.py @@ -131,7 +131,7 @@ class Task(BaseTask): name = tool_name conf = { - 'replace_patterns': ((r'\.js$', '.min.js'),), + '_replace_patterns_': ((r'\.js$', '.min.js'),), } def prepare(self): diff --git a/pybuildtool/tools/woff2svg.py b/pybuildtool/tools/woff2svg.py index 64c0187..cb6732b 100644 --- a/pybuildtool/tools/woff2svg.py +++ b/pybuildtool/tools/woff2svg.py @@ -15,7 +15,7 @@ class Task(BaseTask): conf = { - 'replace_patterns': ((r'\.woff$', '.svg'), (r'\.woff2$', '.svg')) + '_replace_patterns_': ((r'\.woff$', '.svg'), (r'\.woff2$', '.svg')) } name = tool_name diff --git a/pybuildtool/tools/woff2ttf.py b/pybuildtool/tools/woff2ttf.py index c2afb7a..4dfe210 100644 --- a/pybuildtool/tools/woff2ttf.py +++ b/pybuildtool/tools/woff2ttf.py @@ -15,7 +15,7 @@ class Task(BaseTask): conf = { - 'replace_patterns': ((r'\.woff$', '.ttf'), (r'\.woff2$', '.ttf')) + '_replace_patterns_': ((r'\.woff$', '.ttf'), (r'\.woff2$', '.ttf')) } name = tool_name diff --git a/setup.cfg b/setup.cfg index 5aef279..ddb7da9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [metadata] -description-file = README.rst +description_file = README.rst diff --git a/setup.py b/setup.py index 1fd10ff..4368eb4 100644 --- a/setup.py +++ b/setup.py @@ -11,8 +11,8 @@ URL = 'https://github.com/dozymoe/PyBuildTool' EMAIL = 'dozymoe@gmail.com' AUTHOR = 'Fahri Reza' -REQUIRES_PYTHON = '>=2.7.0' -VERSION = '2.0.34' +REQUIRES_PYTHON = '>=3.0.0' +VERSION = '2.0.36' # What packages are required for this module to be executed? REQUIRED = [ @@ -98,7 +98,8 @@ def finalize_options(self): def run(self): self.status('Uploading the package to PyPI via Twine…') - os.system(here + '/run pybin twine upload ' + here + '/dist/*') + os.system('%s pybin twine upload %s' % (os.path.join(here, 'run'), + os.path.join(here, 'dist', '*'))) self.status('Pushing git tags…') os.system('git tag v{0}'.format(about['__version__']))