class RequestWithMethod(urllib2.Request):
"Hack for forcing the method in a request - allows PUT and DELETE"
def __init__(self, method, *args, **kwargs):
- self.method = method
+ # This assignment works directly in older Python versions
+ self._method = method
urllib2.Request.__init__(self, *args, **kwargs)
def get_method(self):
- if self.method:
- return self.method
+ "Deduce the HTTP method to use."
+ # This method works in newer Pythons (2.6.5, possibly earlier).
+ if self._method:
+ return self._method
elif self.has_data():
return "POST"
else:
"POST",
{"url" : {"label": label, "location" : url}})
-def crack_rpm(rpm, meta, urls):
- "Extract freshmeat metadata from an RPM."
- try:
- def get_rpm_field(fld, rpm):
- cmd = "rpm --queryformat='%%{%s}' -qp %s" % (fld, rpm)
- (status, output) = commands.getstatusoutput(cmd)
- if status != 0:
- raise ValueError
- return output
- # Some fields can be copied literally if present.
- if not "name" in meta:
- meta["name"] = get_rpm_field("name", rpm)
- if not "description" in meta:
- meta["description"] = get_rpm_field("description", rpm)
- if not "version" in meta:
- meta["version"] = get_rpm_field("version", rpm)
- # This doesn't work. The values don't map over.
- #if not "license" in meta:
- # meta["license"] = get_rpm_field("license", rpm)
- if not "url_homepage" in meta:
- meta["url_homepage"] = get_rpm_field("url", rpm)
- if not "changelog" in meta:
- # Querying gets you the first entry, apparently
- # blank-line-delimited.
- changes = get_rpm_field("changelogtext", rpm)
- # Canonicalize, stripping leading spaces.
- changes = map(lambda x: x.strip(), changes.split('\n'))
- changes = "\n".join(changes) + "\n"
- meta["changelog"] = changes
- # RPMs have a source field; figure out which Freshmeat field it maps to
- source = get_rpm_field("source", rpm)
- if source.endswith(".tar.gz") or source.endswith(".tgz"):
- if "Tar/GZ" not in urls:
- urls["Tar/GZ"] = source
- if source.endswith(".tar.bz2"):
- if "Tar/BZ" not in urls:
- urls["Tar/BZ"] = source
- except ValueError:
- pass
-
class FreshmeatMetadataFactory:
"Factory class for producing Freshmeat records in JSON."
freshmeat_field_map = (
def header_to_field(self, hdr):
lhdr = hdr.lower().replace("-", "_")
for (alias, shortopt, field) in FreshmeatMetadataFactory.freshmeat_field_map:
- if lhdr == alias.lower().replace("-", "_"):
+ if lhdr == alias.lower().replace("-", "_").replace("/", "_"):
return field
raise FreshmeatSessionException("Illegal field name %s" % hdr)
data = {}
urls = {}
(options, args) = self.argument_parser.parse_args()
- # First stuff from RPMs if present.
- for file in args:
- if file.endswith(".rpm"):
- crack_rpm(file, data, urls)
- # Second, stuff from stdin if present
+ # Stuff from stdin if present
prior_version = data.get("version")
if options.read:
message = self.message_parser.parse(stream)
<refmeta>
<refentrytitle>freshmeat-submit</refentrytitle>
<manvolnum>1</manvolnum>
-<refmiscinfo class='date'>Oct 15 2010</refmiscinfo>
+<refmiscinfo class='date'>Oct 17 2010</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>freshmeat-submit</refname>
that its input format can easily be generated by scripts.</para>
<para><application>freshmeat-submit</application> accepts release
-information from binary packages named in the command line, or from an
-email-message-like data block on standard input, or from command-line
-flags. Values set with command-line flags override those collected
-from standard input, which in turn override those collected from
-binary package files. The accumulated data is entered into the
-freshmeat database via its API.</para>
+information from a job card (an email-message-like data block on
+standard input) or from command-line flags. Values set with
+command-line flags override those collected from the job card. The
+accumulated data is entered into the freshmeat database via its
+API.</para>
<para>A few flags control the operation of
<application>freshmeat-submit</application> itself.</para>
</varlistentry>
</variablelist>
-<para>Release information is accepted from three sources in the
+<para>Release information is accepted from sources in the
following order:</para>
<orderedlist>
-<listitem>
-<para>Binary package files named on the command line. Presently
-the only supported format is RPM. The data from certain RPM tags
-is mined out of the RPM and merged into the release information.</para>
-</listitem>
-
<listitem>
<para>An RFC-2822-format message, strongly resembling an ordinary
email message, on standard input. The message header fields each
specify a particular item of release information; the body (if
present) becomes the change announcement text. Within URL fields, the
-string ${version} will be replaced with the contends of the Version
+string ${version} will be replaced with the contents of the Version
field.</para>
</listitem>
corresponding command-line switches:</para>
<informaltable>
-<tgroup cols='6' rowsep='1'>
+<tgroup cols='5' rowsep='1'>
<thead>
<row>
<entry>Message field</entry>
<entry>Scope</entry>
- <entry>RPM tag</entry>
<entry>Short switch</entry>
<entry>Long switch</entry>
<entry>Explanation</entry>
<tbody>
<row>
-<entry>Project:</entry> <entry>Project</entry> <entry>NAME</entry>
+<entry>Project:</entry> <entry>Project</entry>
<entry>-p</entry><entry>--project</entry>
<entry>
<para>Name of the project (freshmeat shortname) to operate on. You cannot
</row>
<row>
-<entry>Summary:</entry> <entry>Project</entry> <entry>-</entry>
+<entry>Summary:</entry> <entry>Project</entry>
<entry>-S</entry><entry>--summary</entry>
<entry>
<para>One-line summary of the project.</para>
</row>
<row>
-<entry>Description:</entry> <entry>Project</entry> <entry>DESCRIPTION</entry>
+<entry>Description:</entry> <entry>Project</entry>
<entry>-D</entry><entry>--description</entry>
<entry>
-<para>Multiline description of the project.</para>
+<para>Multiline description of the project. (Use RFC-822-style continuation
+lines)</para>
</entry>
</row>
<row>
-<entry>License-List:</entry> <entry>Project</entry> <entry>-</entry>
+<entry>License-List:</entry> <entry>Project</entry>
<entry>-L</entry><entry>--license-list</entry>
<entry>
-<para>Specify the licenses under which the release is issued. This
-may be a comma-separated list. Note that this is not copied from the
-RPM License field, because the values don't map.</para>
+<para>Specify the licenses under which the project is issued. This
+may be a comma-separated list.</para>
</entry>
</row>
<row>
-<entry>Project-Tag-List:</entry><entry>Release</entry> <entry>-</entry>
+<entry>Project-Tag-List:</entry><entry>Release</entry>
<entry>-T</entry><entry>--project-tag-list</entry>
<entry>
<para>Tags to attach to this project. May be a comma-separated list.</para>
</row>
<row>
-<entry>Version:</entry> <entry>Release</entry> <entry>VERSION</entry>
+<entry>Version:</entry> <entry>Release</entry>
<entry>-v</entry><entry>--version</entry>
<entry>
-<para>Version string to be associated with the release.
-Conventionally this will look like n.n or n.n.n, where each n
-is decimal digits.</para>
+<para>Version string to be associated with the release.</para>
</entry>
</row>
<row>
-<entry>Changes:</entry> <entry>Release</entry> <entry>CHANGELOGTEXT</entry>
+<entry>Changes:</entry> <entry>Release</entry>
<entry>-c</entry><entry>--changes</entry>
<entry>
-<para>The Changes field. Plain text, no more than 600 characters.
-If no Changes field or option is already present, the changes text is taken
-from the body of the RFC-822 message on standard input.</para>
+<para>The Changes field. If no Changes field or option is already
+present, the changes text is taken from the body of the RFC-822
+message on standard input.</para>
</entry>
</row>
<row>
-<entry>Release-Focus:</entry><entry>Release</entry> <entry>-</entry>
+<entry>Release-Focus:</entry><entry>Release</entry>
<entry>-r</entry><entry>--release-focus</entry>
<entry>
<para>Purpose of this release. See the table of release-focus types
</row>
<row>
-<entry>Release-Tag-List:</entry> <entry>Release</entry> <entry>-</entry>
+<entry>Release-Tag-List:</entry> <entry>Release</entry>
<entry>-t</entry><entry>--tag-list</entry>
<entry>
<para>Tags to attach to this release. May be a comma-separated list.</para>
</row>
<row>
-<entry>Hide:</entry> <entry>Release</entry> <entry>-</entry>
+<entry>Hide:</entry> <entry>Release</entry>
<entry>-x</entry><entry>--hide</entry>
<entry>
<para>If this field is present and has the value “Y”, this
</row>
<row>
-<entry>Website-URL:</entry> <entry>Project</entry> <entry>URL</entry>
-<entry>-H</entry><entry>--home-page-url</entry><entry>
+<entry>Website-URL:</entry> <entry>Project</entry>
+<entry>-H</entry><entry>--website-url</entry><entry>
<para>Specify the project home page.</para>
</entry>
</row>
<row>
-<entry>Tar/GZ-URL:</entry> <entry>Project</entry> <entry>SOURCE</entry>
-<entry>-G</entry><entry>--gzipped-tar-url</entry>
+<entry>Tar/GZ-URL:</entry> <entry>Project</entry>
+<entry>-G</entry><entry>--tar-gz-url</entry>
+<entry>
+<para>Specify the URL where a gzipped tarball of source can be found.</para>
+</entry>
+
+<row>
+<entry>Changelog-URL:</entry> <entry>Project</entry>
+<entry>-G</entry><entry>--changelog-url</entry>
<entry>
<para>Specify the URL where a gzipped tarball of source can be found.</para>
</entry>
version lifts 96% of 9829 manual pages in a full Red Hat 9
installation with Fedora updates to *validated* XML-DocBook.
</programlisting>
-
-<para>You may run this program in a directory where you have already
-made an RPM, giving it the RPM as a file argument. In that case, all
-you will normally need to supply is the Release-Focus field; the other
-required fields (including, most notably, the Changes field) will be
-mined out of the RPM.</para>
</refsect1>
<refsect1><title>WARNING</title>
<para>There is no longer a Branch attribute.</para>
<para>The old Release-Focus field is gone. As a special case, this
-pragram will validate it and use it to fill in the tags list.</para>
+pragram will validate it and use it to fill in the project tags list.</para>
<para>The old License field is now License-List and can take a
comma-separated list of licenses.</para>
-<para>The old Home-Page-URL is noe Website-URL to match the convention
+<para>The old Home-Page-URL is now Website-URL to match the convention
used by the new API.</para>
<para>The old Gzipped-Tar-URL is now Tar/GZ-URL to match the convention
<para>All the other special-case URL fields are gone. They're replaced by
the general mechanism for pairing URLs with labels.</para>
+
+<para>Earlier versions parsed RPM specfiles. This was poor
+separation of function and has been removed. That responsibility
+belong to the human or program generating the job card.</para>
</refsect1>
<refsect1><title>FILES</title>