示例#1
0
with NML; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."""

import sys, os, codecs, optparse
from nml import generic, grfstrings, parser, version_info, output_nml, output_nfo, output_grf, output_dep, palette, spriteencoder, spritecache, global_constants
from nml.actions import action2layout, action2var, action8, sprite_count, real_sprite, action4, action0, action1, action2, action6, action7, action11, actionF
from nml.ast import grf, alt_sprites

try:
    from PIL import Image
except ImportError:
    pass

developmode = False  # Give 'nice' error message instead of a stack dump.

version = version_info.get_nml_version()


def parse_cli(argv):
    """
    Parse the command line, and process options.

    @return: Options, and input filename (if not supplied, use C{sys.stdin}).
    @rtype:  C{tuple} (C{Object}, C{str} or C{None})
    """
    usage = "Usage: %prog [options] <filename>\n" \
            "Where <filename> is the nml file to parse"

    opt_parser = optparse.OptionParser(usage=usage,
                                       version=version_info.get_cli_version())
    opt_parser.set_defaults(debug=False,
示例#2
0
文件: setup.py 项目: getttd/nml
#!/usr/bin/env python3

import os

from setuptools import setup, Extension, find_packages
from setuptools.command.build_py import build_py

try:
    # Update the version by querying git if possible.
    from nml import version_update
    NML_VERSION = version_update.get_and_write_version()
except ImportError:
    # version_update is excluded from released tarballs, so that
    #  only the predetermined version is used when building from one.
    from nml import version_info
    NML_VERSION = version_info.get_nml_version()


class NMLBuildPy(build_py):
    def run(self):
        # Create a parser so that nml/generated/{parse,lex}tab.py are generated.
        from nml import parser
        parser.NMLParser(rebuild=True)
        # Then continue with the normal setuptools build.
        super().run()


setup(name='nml',
      version=NML_VERSION,
      packages=find_packages(),
      description='An OpenTTD NewGRF compiler for the nml language',