Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
pypi/parse.rb: Formatting of the abstract and switch to general outpu…
Browse files Browse the repository at this point in the history
…t format

This now uses the format: "Package description: the package description
goes here." The first letter of the abstract is lowercased unless the
second letter was originally capitlalized too, signaling an acronym.

It's using the general output format instead of the programming
format now too. Thanks to ezgraphs for including both formats in the
code!
  • Loading branch information
rpicard committed Jun 11, 2012
1 parent eb885fe commit d25bd1e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pypi/parse.rb
Expand Up @@ -35,8 +35,19 @@ def get_item(doc,label='Author:', child_tag="span")
page = a[0]

next if abstract == "UNKNOWN" || abstract == ""

# Test if the first word is an acronym
isAcronym = abstract =~ /^.[A-Z]/


abstract = "Package description - #{abstract}" unless a[1].nil?
# Lowercase the first letter for formatting "Package description: abstract goes here"
unless isAcronym
firstChar = abstract.split(//).first.downcase
abstract.slice!(0)
abstract = firstChar + abstract
end

abstract = "Package description: #{abstract}" unless a[1].nil?

# Get the License and Home Page of the project from the detail page if available
# 06.07.2012 - Was having problems opening the URL so I've commented this out for now
Expand All @@ -53,10 +64,11 @@ def get_item(doc,label='Author:', child_tag="span")
abstract.gsub!("\n", ' ')
abstract.gsub!("\r", ' ')
end

# puts "#{page}\tA\t\t\t#{categories}\t\t#{internal_links}\t\t#{external_links}\t\t#{images}\t#{abstract}\t#{source_url}\n"

# Use general format
puts "#{page}\tA\t\t\t#{categories}\t\t#{internal_links}\t\t#{external_links}\t\t#{images}\t#{abstract}\t#{source_url}\n"
# Use programming format.
puts "#{page}\t\t#{source_url}\t#{abstract}\t\t\t\t\n"
# puts "#{page}\t\t#{source_url}\t#{abstract}\t\t\t\t\n"

end

Expand Down

0 comments on commit d25bd1e

Please sign in to comment.