Skip to Content.
Sympa Menu

sm-discuss - [SM-Discuss] patch to quill for freshmeat.net

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: Andrew <afrayedknot AT thefrayedknot.armory.com>
  • To: sm-discuss AT lists.ibiblio.org
  • Subject: [SM-Discuss] patch to quill for freshmeat.net
  • Date: Thu, 23 Jun 2005 23:44:04 -0700

Hi, as if quill doesnt make spell writing easy enough...attached is a
patch to make it fetch xml project data from freshmeat.net and attempt
to answer some of the queries with it for you. It requires xml-twig and
curl to be installed.

To use it pass --fmxml <project name|xml url>

If you use project name, it will derive a url, if you give a url it will
download xml data from there. The functionality is completely optional,
if you dont use the --fmxml argument no noticable changes will occur. For
each of the values it fills in, you will be given the option of modifying
it, just in case it is incorrect.

Of course, the feature's usefulness is proportional to the usefulness
of the freshmeat project page, if theres no/poor data, there is little
gain. I tested on a subset of spells and it seems to work fairly well.

A future improvement would be to to parse the dependency values out, not
all projects have this, but its yet another thing that can be automated
if it exists. It shouldn't be too hard with a small perl/python/etc
script using a xml parsing module if someone wants to try.

Another future improvement would be to fix the license parsing code. I
only implemented a very simple algorithm.

Let me know if there are any problems or suggestions. Hopefully this
can get merged into the main version of quill.

-Andrew

--
__________________________________________________________________________
|Andrew D. Stitt | astitt at sourcemage.org |
|irc: afrayedknot | afrayedknot at t.armory.com |
|aim: thefrayedknot or iteratorplusplus | acedit at armory.com |
|Sorcery Team Lead | ftp://t.armory.com/ |
--------------------------------------------------------------------------

--- quill 2005-06-23 23:17:11.000000000 -0700
+++ quill 2005-05-17 21:37:17.000000000 -0700
@@ -42,23 +42,6 @@

}

-function grab_from_xml() {
- xml_grep --text_only $1 $FRESHMEAT_FILE
-}
-
-
-function hunt_src_url() {
- local URL
- local SPELL_NAME=$1
- URL=$(curl -I $2 2>/dev/null|grep Location|awk '{print $2}'|sed 's/\r//g')
- # hacky attempt to get source url from sourceforge
- if echo $URL|grep -q sourceforge; then
- curl $URL 2>/dev/null|tr '<>' '\n\n'|grep http|grep sourceforge|grep
download|grep -i $SPELL_NAME|
- cut -f2 -d\"|cut -f1 -d?|head -n 1
- else
- echo $URL
- fi
-}

#---
## Some basic stuff that should be loaded and set
@@ -103,39 +86,6 @@
POSTINSTALLISON=""
FINALISON=""

-
-if [[ $1 == --fmxml ]] && [[ $2 ]]; then
- FRESHMEAT_XML=$2
- if ! which xml_grep &>/dev/null; then
- message "You need xml-twig with xml_grep installed to use freshmeat mode"
- exit 1
- fi
- if ! which curl &>/dev/null; then
- message "You need curl to use freshmeat mode"
- exit 1
- fi
- # if the argument looks like a url then use that, otherwise
- # assume the argument is the name of the spell and construct a
- # url for where we think freshmeat.net stores their xml data
- if echo $FRESHMEAT_XML|grep -q http://; then
- FRESHMEAT_XML_URL=$FRESHMEAT_XML
- else
-
FRESHMEAT_XML_URL=http://freshmeat.net/projects-xml/$FRESHMEAT_XML/${FRESHMEAT_XML}.xml
- fi
- # check if we already have the xml file, if we dont, download it
- if test -f $FRESHMEAT_XML.xml ; then
- FRESHMEAT_FILE=${FRESHMEAT_XML}.xml
- else
- if ! url_download $FRESHMEAT_XML_URL ; then
- message "Failed to get $FRESHMEAT_XML"
- exit 1
- fi
- FRESHMEAT_FILE=$FILE
- unset FILE
- fi
-fi
-
-
## Down to here... from here it's question and answer time
#---

@@ -154,65 +104,26 @@
message "space delimited and not coma delimited${DEFAULT_COLOR}"
message
"-----------------------------------------------------------------------------"

-# fill in variables from xml file
-if [[ $FRESHMEAT_XML ]] ; then
- SPELL_NAME=$(grab_from_xml projectname_short|tr 'A-Z' 'a-z')
- for each in url_bz2 url_tgz; do
- TMP=$(grab_from_xml $each)
- if [[ $TMP ]] ; then
- SPELL_SRC_URL=$(hunt_src_url $SPELL_NAME $TMP)
- break
- fi
- done
- SPELL_URL=$(curl -I $(grab_from_xml url_homepage) 2>&1|grep Location|awk
'{print $2}'|sed 's/\r//g')
- SPELL_LICENSE=$(grab_from_xml license|awk '{print $NF}'|tr -d '()')
- SPELL_SHORT_DESCRIPTION=$(grab_from_xml desc_short|sed 's/\r//g')
- grab_from_xml desc_full|fmt > ~/tmp/${SPELL_NAME}
-fi
-
-# for all the fields that could be filled in, check if they were filled in
-# and if so, give the user an opportunity to change the value
-if ! [[ $SPELL_NAME ]] ||
- ! query "Is $SPELL_NAME the proper spell name?" y; then
- message "${QUERY_COLOR}Please enter the spell name:${DEFAULT_COLOR}"
- read "SPELL_NAME"
-fi
-
-if ! [[ $SPELL_SRC_URL ]] ||
- ! query "Is $SPELL_SRC_URL the proper source url?" y; then
- message "${QUERY_COLOR}Please enter the url of the source:${DEFAULT_COLOR}"
- read "SPELL_SRC_URL"
-fi
-
-if ! [[ $SPELL_LICENSE ]] ||
- ! query "Is $SPELL_LICENSE the proper license?" y; then
- message "${QUERY_COLOR}Please enter the license of the
spell:${DEFAULT_COLOR}"
- read "SPELL_LICENSE"
-fi
-
-if ! [[ $SPELL_URL ]] ||
- ! query "Is $SPELL_URL the proper website?" y; then
- message "${QUERY_COLOR}Please enter a website for the
spell:${DEFAULT_COLOR}"
- read "SPELL_URL"
-fi
-
-if ! [[ $SPELL_SHORT_DESCRIPTION ]] ||
- ! ( message "${QUERY_COLOR}Is${DEFAULT_COLOR}\n$SPELL_SHORT_DESCRIPTION"
- query "the proper short description?${DEFAULT_COLOR}" y ; ) ; then
- message "${QUERY_COLOR}Please enter a short description of the
spell:${DEFAULT_COLOR}"
- read "SPELL_SHORT_DESCRIPTION"
-fi
-
-if ! test -f ~/tmp/${SPELL_NAME} ||
- ! ( message "${QUERY_COLOR}Is${DEFAULT_COLOR}"
- cat ~/tmp/${SPELL_NAME}
- query "the proper long description?${DEFAULT_COLOR}" y ; ) ; then
- message "${QUERY_COLOR}Please enter a description of the
spell:${DEFAULT_COLOR}"
- sleep 2
- message "${PROBLEM_COLOR}!!!PRESS ENTER TO CONTINUE!!!${DEFAULT_COLOR}"
- read
- ${EDITOR:-nano} ~/tmp/${SPELL_NAME}
-fi
+message "${QUERY_COLOR}Please enter the spell name:${DEFAULT_COLOR}"
+read "SPELL_NAME"
+
+message "${QUERY_COLOR}Please enter the url of the source:${DEFAULT_COLOR}"
+read "SPELL_SRC_URL"
+
+message "${QUERY_COLOR}Please enter the license of the
spell:${DEFAULT_COLOR}"
+read "SPELL_LICENSE"
+
+message "${QUERY_COLOR}Please enter a website for the spell:${DEFAULT_COLOR}"
+read "SPELL_URL"
+
+message "${QUERY_COLOR}Please enter a short description of the
spell:${DEFAULT_COLOR}"
+read "SPELL_SHORT_DESCRIPTION"
+
+message "${QUERY_COLOR}Please enter a description of the
spell:${DEFAULT_COLOR}"
+sleep 2
+message "${PROBLEM_COLOR}!!!PRESS ENTER TO CONTINUE!!!${DEFAULT_COLOR}"
+read
+${EDITOR:-nano} ~/tmp/${SPELL_NAME}

message "${QUERY_COLOR}Please enter the dependencies(non optional) of the
spell if any:${DEFAULT_COLOR}"
read "SPELL_DEPENDENCIES"

Attachment: pgptDPsi9v9Em.pgp
Description: PGP signature




Archive powered by MHonArc 2.6.24.

Top of Page