diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-08-01 21:51:50 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-08-01 21:58:37 -0700 |
commit | d53d9bf0e55fddd814ad99ec89134a7228390c65 (patch) | |
tree | 7c1a4a214a8e81c9ed28ac4ea3acc7826796781c /attoconf | |
parent | a3405560a639e8ee90457d78a9b393dde91d8781 (diff) | |
download | attobuild-d53d9bf0e55fddd814ad99ec89134a7228390c65.tar.gz attobuild-d53d9bf0e55fddd814ad99ec89134a7228390c65.tar.bz2 attobuild-d53d9bf0e55fddd814ad99ec89134a7228390c65.tar.xz attobuild-d53d9bf0e55fddd814ad99ec89134a7228390c65.zip |
Put some important files in a skeleton
Diffstat (limited to 'attoconf')
-rw-r--r-- | attoconf/_version.py | 18 | ||||
-rw-r--r-- | attoconf/core.py | 82 | ||||
-rw-r--r-- | attoconf/version.py | 39 |
3 files changed, 139 insertions, 0 deletions
diff --git a/attoconf/_version.py b/attoconf/_version.py new file mode 100644 index 0000000..7721bb4 --- /dev/null +++ b/attoconf/_version.py @@ -0,0 +1,18 @@ +# Implementation of Semantic Versioning +# This file should change in every single commit. + +# Incremented for releases with incompatible API changes. +# 0 is special, for initial releases with no real guarantees. +major = 0 + +# Incremented for releases with compatible API additions. +# This is the number that is usually incremented. +minor = 0 + +# Incremented if there is a bugfix release. +# Might not be contiguous. +patch = 0 + +# Reserved for distributors and forks. +# Contains arbitrary text, but no parentheses or newlines. +distributor = 'Vanilla' diff --git a/attoconf/core.py b/attoconf/core.py new file mode 100644 index 0000000..0c01d5e --- /dev/null +++ b/attoconf/core.py @@ -0,0 +1,82 @@ +# Copyright 2013 Ben Longbons <b.r.longbons@gmail.com> +# +# This file is part of attoconf. +# +# attoconf is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# attoconf is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with attoconf. If not, see <http://www.gnu.org/licenses/>. + +from __future__ import print_function, division, absolute_import + +class Project(object): + ''' A Project is a directory and the list of options that can be set. + ''' + __slots__ = ( + 'aliases', + 'options', + 'help', + ) + def __init__(self, srcdir): + ''' A Project is initially constructed from just the source directory + ''' + + def add_help(self, text, hidden): + ''' Directly add a line of text to the help. + ''' + + def add_alias(self, key, expansion, help, hidden): + ''' Add an alias. + + This is necessary for anything to appear without an =. + + The expansion is a list of other options, which may be aliases. + ''' + + def add_option(self, name, init, type, check, help, hidden): + ''' Add an actual option. + + This must be passed with a =. + + In the builder, the var will first be set to init. + + If the argument is passed, the type hook is called immediately + to validate the argument. + + The check hooks will be called at final time, + in the order they were added. + + Additionally, a line of help is added, with additional formatting. + ''' + +class Build(object): + ''' A Build is a directory and set of options applied to a Project. + ''' + __slots__ = ( + 'project', + 'vars', + ) + def __init__(self, project, bindir): + ''' A Build is initially constructed from + ''' + + def apply_arg(self, arg): + ''' Parse a single argument, expanding aliases. + ''' + + def finish(self): + ''' With the current set of variables, run all the checks + and presumably produce some sort of output. + ''' + + def configure(self, args, env): + ''' Automatically call apply_arg() a bunch of times, then finish(). + ''' diff --git a/attoconf/version.py b/attoconf/version.py new file mode 100644 index 0000000..231a3d1 --- /dev/null +++ b/attoconf/version.py @@ -0,0 +1,39 @@ +# Copyright 2013 Ben Longbons <b.r.longbons@gmail.com> +# +# This file is part of attoconf. +# +# attoconf is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# attoconf is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with attoconf. If not, see <http://www.gnu.org/licenses/>. + +from __future__ import print_function, division, absolute_import + +import sys + +from . import _version + +if sys.version_info[0] != 2 or sys.version_info[1] < 7: + sys.exit('Unsupported Python version: %s\nRequire Python 2.7' % sys.version) + +def require_version(major, minor, patch=0): + ''' Check that this is the right version of attoconf, or die trying. + ''' + + actual = 'Current version: ' + string + if major != _version.major: + sys.exit('Unsupported major version: %d\n' % major + actual) + if minor > _version.minor: + sys.exit('Unsupported minor version: %d.%d\n' % (major, minor) + actual) + if minor == _version.minor and patch > _version.patch: + sys.exit('Unsupported patch version: %d.%d.%d\n' % (major, minor, patch) + actual) + +string = 'attoconf %d.%d.%d (%s)' % (_version.major, _version.minor, _version.patch, _version.distributor) |