Blame SOURCES/nodejs.prov

30582b
#!/usr/bin/python
30582b
30582b
"""
30582b
Automatic provides generator for Node.js libraries.
30582b
30582b
Taken from package.json.  See `man npm-json` for details.
30582b
"""
30582b
# Copyright 2012 T.C. Hollingsworth <tchollingsworth@gmail.com>
30582b
#
30582b
# Permission is hereby granted, free of charge, to any person obtaining a copy
30582b
# of this software and associated documentation files (the "Software"), to
30582b
# deal in the Software without restriction, including without limitation the
30582b
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
30582b
# sell copies of the Software, and to permit persons to whom the Software is
30582b
# furnished to do so, subject to the following conditions:
30582b
#
30582b
# The above copyright notice and this permission notice shall be included in
30582b
# all copies or substantial portions of the Software.
30582b
#
30582b
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30582b
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30582b
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30582b
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30582b
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30582b
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30582b
# IN THE SOFTWARE.
30582b
30582b
import json
30582b
import subprocess
30582b
import sys
30582b
30582b
paths = [path.rstrip() for path in sys.stdin.readlines()]
30582b
30582b
for path in paths:
30582b
    if path.endswith('package.json'):
30582b
        fh = open(path)
30582b
        metadata = json.load(fh)
30582b
        fh.close()
30582b
30582b
        if 'name' in metadata and not ('private' in metadata and metadata['private']):
30582b
            print 'nodejs010-npm(' + metadata['name'] + ')',
30582b
30582b
            if 'version' in metadata:
30582b
                print '= ' + metadata['version']
30582b
            else:
30582b
                print
30582b
30582b
# invoke the regular RPM provides generator                
30582b
p = subprocess.Popen(['/usr/lib/rpm/find-provides'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
30582b
print p.communicate(input='\n'.join(paths))[0]