Esempio n. 1
0
def initNonInteractive(args, c):
    if not 'name' in c.description:
        c.description['name'] = validate.componentNameCoerced(os.path.split(os.getcwd())[1])

    if not 'version' in c.description:
        c.setVersion("0.0.0")

    if not 'description' in c.description:
        c.description['description'] = defaultDescription()

    if not 'keywords' in c.description:
        c.description['keywords'] = []

    if not 'author' in c.description:
        c.description['author'] = defaultAuthor()

    if not 'repository' in c.description:
        c.description['repository'] = repoObject('[email protected]:yourName/%s' % c.description['name'])

    if not 'homepage' in c.description:
        c.description['homepage'] = '%s-module-homepage.com' % c.description['name']

    if not 'license' in c.description and not 'licenses' in c.description:
        c.description['license'] = defaultLicense()

    if not 'dependencies' in c.description:
        c.description['dependencies'] = {}

    createFolders(c)
    c.writeDescription()
Esempio n. 2
0
 def test_componentNameCoerced(self):
     self.assertTrue('some-name' == validate.componentNameCoerced('Some Name'))
     self.assertTrue('some-name' == validate.componentNameCoerced('Some  Name'))
     self.assertTrue('moo-moo-moo' == validate.componentNameCoerced('MOO!!!!MOO-----Moo'))
Esempio n. 3
0
def initInteractive(args, c):
    def current(x):
        return c.description[x] if x in c.description else None

    default_name = c.getName()
    if not default_name:
        default_name = validate.componentNameCoerced(os.path.split(os.getcwd())[1])
    if isBannedName(default_name):
        default_name = 'unnamed'

    c.setName(getUserInput("Enter the module name:", default_name, notBannedName))
    c.setVersion(getUserInput("Enter the initial version:", str(c.getVersion() or "0.0.0"), version.Version))

    default_isexe = 'no'
    if current('bin'):
        default_isexe = 'yes'
    isexe = getUserInput("Is this an executable (instead of a re-usable library module)?", default_isexe, yesNo)
    if isexe:
        c.description['bin'] = './source'
        # set exe modules to private by default, to prevent publishing
        # applications
        if current('private') is None:
            c.description['private'] = True

    description = getUserInput("Short description: ", current('description'))
    if len(description):
        c.description['description'] = description
    elif 'description' in c.description:
        del c.description['description']

    if not isexe:
        c.description['keywords']    = getUserInput("Keywords: ", ' '.join(current('keywords') or []), listOfWords)
    c.description['author']      = getUserInput("Author: ", current('author'))

    if not isexe:
        current_repo_url = current('repository')
        if isinstance(current_repo_url, dict):
            current_repo_url = current_repo_url['url']
        new_repo_url = getUserInput("Repository url (where people can submit bugfixes): ", current_repo_url, repoObject)
        if new_repo_url:
            c.description['repository'] = new_repo_url

        new_homepage = getUserInput("Homepage: ", current('homepage'))
        if (not len(new_homepage.strip())) and 'homepage' in c.description:
            del c.description['homepage']
        elif len(new_homepage.strip()):
            c.description['homepage'] = new_homepage

    if not current('licenses') or current('license'):
        license = getUserInput('What is the license for this project (Apache-2.0, ISC, MIT etc.)? ', 'Apache-2.0')
        if license.lower().strip() in Known_Licenses:
            c.description['license'] = Known_Licenses[license.lower().strip()]
        else:
            c.description['license'] = license

    c.description['dependencies'] = current('dependencies') or {}

    if isexe:
        createFolders(c, 'executable')
    else:
        createFolders(c, 'library')
    c.writeDescription()