mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
Add conf/profile
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
24ba182fa1
commit
74a27f1c19
4 changed files with 23 additions and 8 deletions
4
conf/Makefile
Normal file
4
conf/Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
TOPDIR = ..
|
||||||
|
|
||||||
|
include $(TOPDIR)/make/proj.mk
|
||||||
|
include $(MODDIR)/make/dirs.mk
|
||||||
4
conf/profile/Makefile
Normal file
4
conf/profile/Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
TOPDIR = ../..
|
||||||
|
|
||||||
|
include $(TOPDIR)/make/proj.mk
|
||||||
|
include $(MODDIR)/make/profile.mk
|
||||||
|
|
@ -29,13 +29,12 @@ class TrimSourceCmd(jwutils.Cmd):
|
||||||
for path in args.input:
|
for path in args.input:
|
||||||
with open(path, 'r+') as infile:
|
with open(path, 'r+') as infile:
|
||||||
contents = infile.read()
|
contents = infile.read()
|
||||||
|
name = os.path.basename(path)
|
||||||
|
ext = os.path.splitext(path)[1]
|
||||||
|
|
||||||
# TODO: support other types in this block
|
# TODO: support other types in this block
|
||||||
mime = magic.detect_from_content(contents).mime_type
|
mime = magic.detect_from_content(contents).mime_type
|
||||||
if mime != 'text/plain':
|
if mime in [ 'text/plain', 'application/x-empty' ]:
|
||||||
raise Exception("unsupported file type", mime, "of", path)
|
|
||||||
name = os.path.basename(path)
|
|
||||||
ext = os.path.splitext(path)[1]
|
|
||||||
if name != 'Makefile' and ext != '.mk':
|
if name != 'Makefile' and ext != '.mk':
|
||||||
raise Exception("unsupported file type of", path)
|
raise Exception("unsupported file type of", path)
|
||||||
mime = 'text/x-makefile'
|
mime = 'text/x-makefile'
|
||||||
|
|
@ -55,6 +54,8 @@ class CmdBeautify(TrimSourceCmd):
|
||||||
return p
|
return p
|
||||||
|
|
||||||
def _processTextXMakefile(self, args, mime, path, contents):
|
def _processTextXMakefile(self, args, mime, path, contents):
|
||||||
|
|
||||||
|
# -- assignments
|
||||||
r = ''
|
r = ''
|
||||||
indent = args.indent_assignments
|
indent = args.indent_assignments
|
||||||
for line in contents.splitlines(True):
|
for line in contents.splitlines(True):
|
||||||
|
|
@ -63,6 +64,12 @@ class CmdBeautify(TrimSourceCmd):
|
||||||
r += line
|
r += line
|
||||||
continue
|
continue
|
||||||
r += misc.pad(m.group(1), indent - len(m.group(2))) + m.group(2) + m.group(3) + ' ' + m.group(4) + '\n'
|
r += misc.pad(m.group(1), indent - len(m.group(2))) + m.group(2) + m.group(3) + ' ' + m.group(4) + '\n'
|
||||||
|
|
||||||
|
# -- trailing white space
|
||||||
|
contents = r
|
||||||
|
r = ''
|
||||||
|
for line in contents.splitlines(False):
|
||||||
|
r += line.rstrip() + '\n'
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def _run(self, args, mime, path, contents):
|
def _run(self, args, mime, path, contents):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue