2 # -*- coding: utf-8 -*-
5 from manga_py
import meta
7 RE_VALID_PACKAGE
= re
.compile(r
'^([a-zA-Z-_]+)')
8 RE_REPLACE_SETUP_REQ
= re
.compile(r
'^(REQUIREMENTS\s*=\s*\[)(.*\])$')
12 with
open('requirements.txt', 'r') as _r
:
13 return [line
.strip() for line
in _r
.readlines() if RE_VALID_PACKAGE
.search(line
)]
16 with
open('manga_py/cli/_requirements.py', 'w') as w
:
17 w
.write('requirements = ["%s"]' % '","'.join(req_lines()))
21 requirements
= ''.join(["'%s', " % line
for line
in req_lines()])
23 for n
, line
in enumerate(lines
):
24 matched
= RE_REPLACE_SETUP_REQ
.search(line
)
25 if matched
is not None:
26 _b
, _a
= matched
.groups()
27 lines
[n
] = '%s%s%s' % (_b
, requirements
, _a
)
33 with
open('setup.py.template', 'r') as r
:
36 for key
in meta
.__all
__:
37 content
= content
.replace('__%s__' % key
, getattr(meta
, key
))
39 with
open('setup.py', 'w') as w
:
40 w
.write('\n'.join(req(content
.splitlines())))