mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-21 17:52:00 +02:00
19.0 vanilla
This commit is contained in:
parent
0a7ae8db93
commit
991d2234ca
416 changed files with 646602 additions and 300844 deletions
|
|
@ -1,24 +1,25 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import jinja2
|
||||
|
||||
from . import Command
|
||||
|
||||
|
||||
class Scaffold(Command):
|
||||
""" Generates an Odoo module skeleton. """
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.epilog = "Built-in templates available are: %s" % ', '.join(
|
||||
d for d in os.listdir(builtins())
|
||||
if d != 'base'
|
||||
)
|
||||
|
||||
def run(self, cmdargs):
|
||||
# TODO: bash completion file
|
||||
parser = argparse.ArgumentParser(
|
||||
prog=f'{Path(sys.argv[0]).name} {self.name}',
|
||||
description=self.__doc__,
|
||||
epilog=self.epilog(),
|
||||
)
|
||||
parser = self.parser
|
||||
parser.add_argument(
|
||||
'-t', '--template', type=template, default=template('default'),
|
||||
help="Use a custom module template, can be a template name or the"
|
||||
|
|
@ -47,11 +48,6 @@ class Scaffold(Command):
|
|||
params=params,
|
||||
)
|
||||
|
||||
def epilog(self):
|
||||
return "Built-in templates available are: %s" % ', '.join(
|
||||
d for d in os.listdir(builtins())
|
||||
if d != 'base'
|
||||
)
|
||||
|
||||
builtins = lambda *args: os.path.join(
|
||||
os.path.abspath(os.path.dirname(__file__)),
|
||||
|
|
@ -82,7 +78,7 @@ def directory(p, create=False):
|
|||
if create and not os.path.exists(expanded):
|
||||
os.makedirs(expanded)
|
||||
if not os.path.isdir(expanded):
|
||||
die("%s is not a directory" % p)
|
||||
sys.exit("%s is not a directory" % p)
|
||||
return expanded
|
||||
|
||||
env = jinja2.Environment()
|
||||
|
|
@ -100,7 +96,7 @@ class template(object):
|
|||
self.path = identifier
|
||||
if os.path.isdir(self.path):
|
||||
return
|
||||
die("{} is not a valid module template".format(identifier))
|
||||
sys.exit(f"{identifier} is not a valid module template")
|
||||
|
||||
def __str__(self):
|
||||
return self.id
|
||||
|
|
@ -141,10 +137,6 @@ class template(object):
|
|||
.dump(f, encoding='utf-8')
|
||||
f.write(b'\n')
|
||||
|
||||
def die(message, code=1):
|
||||
print(message, file=sys.stderr)
|
||||
sys.exit(code)
|
||||
|
||||
def warn(message):
|
||||
# ASK: shall we use logger ?
|
||||
print("WARNING:", message)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue