88a3cda
#!/usr/bin/python
88a3cda
88a3cda
"""
88a3cda
Automatic provides generator for Drupal 7 modules, profiles, and themes.
88a3cda
88a3cda
Parsed from *.info files.
039b1a5
039b1a5
First command line argument is used as version if provided.
88a3cda
"""
88a3cda
88a3cda
# Copyright 2013 Shawn Iwinski <shawn.iwinski@gmail.com>
88a3cda
#
88a3cda
# Permission is hereby granted, free of charge, to any person obtaining a copy
88a3cda
# of this software and associated documentation files (the "Software"), to
88a3cda
# deal in the Software without restriction, including without limitation the
88a3cda
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
88a3cda
# sell copies of the Software, and to permit persons to whom the Software is
88a3cda
# furnished to do so, subject to the following conditions:
88a3cda
#
88a3cda
# The above copyright notice and this permission notice shall be included in
88a3cda
# all copies or substantial portions of the Software.
88a3cda
#
88a3cda
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88a3cda
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
88a3cda
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
88a3cda
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88a3cda
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
88a3cda
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
88a3cda
# IN THE SOFTWARE.
88a3cda
039b1a5
import re
88a3cda
import sys
88a3cda
import os
88a3cda
88a3cda
039b1a5
RE_HIDDEN = re.compile(r'hidden\s*=\s*TRUE', re.IGNORECASE)
039b1a5
039b1a5
88a3cda
def main():
039b1a5
    version = sys.argv[1] if len(sys.argv) > 1 else None
039b1a5
    paths   = [path.rstrip() for path in sys.stdin.readlines()]
88a3cda
88a3cda
    for path in paths:
039b1a5
        if path.endswith('.info') and not re.search(RE_HIDDEN, open(path).read()):
039b1a5
            print 'drupal7(' + os.path.basename(path)[:-len('.info')] + ')',
039b1a5
            if version is not None:
039b1a5
                print '=', version
039b1a5
            else:
039b1a5
                print ''
88a3cda
88a3cda
88a3cda
if __name__ == '__main__':
88a3cda
    main()