Blame SOURCES/nodejs.prov

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