Add conf/profile

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2017-11-18 15:43:49 +01:00
commit 74a27f1c19
4 changed files with 23 additions and 8 deletions

4
conf/Makefile Normal file
View file

@ -0,0 +1,4 @@
TOPDIR = ..
include $(TOPDIR)/make/proj.mk
include $(MODDIR)/make/dirs.mk

4
conf/profile/Makefile Normal file
View file

@ -0,0 +1,4 @@
TOPDIR = ../..
include $(TOPDIR)/make/proj.mk
include $(MODDIR)/make/profile.mk

View file

@ -29,16 +29,15 @@ 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) if name != 'Makefile' and ext != '.mk':
name = os.path.basename(path) raise Exception("unsupported file type of", path)
ext = os.path.splitext(path)[1] mime = 'text/x-makefile'
if name != 'Makefile' and ext != '.mk':
raise Exception("unsupported file type of", path)
mime = 'text/x-makefile'
out = self._run(args, mime, path, contents) out = self._run(args, mime, path, contents)
infile.seek(0) infile.seek(0)
@ -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):