In practice, I had to change this:
if len(query) > 0 and query[-1] == query[-1].capitalize(): group =
query.pop()
to this:
if len(query) > 0 and query[-1][0] == query[-1].capitalize()[0]:
group = query.pop()
This is because I only wanted to test the case of the first letter of
the string.
--
This is what I ended up with. Slightly different approach:
import urlparse
def sUrl(s):
page = group = ''
bits = urlparse.urlsplit(s)
url = '//'.join([bits[0],bits[1]]) + '/'
query = bits[2].split('/')
if '' in query: query.remove('')
if len(query) > 1: page = quer
"Ben Wilson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am working on a script that splits a URL into a page and a url. The
> examples below are the conditions I expect a user to pass to the
> script. In all cases, "http://www.example.org/test/"; is the URL, and
> the page comp
Sorry.
I'm writing a python script that retrieves source contents of a wiki
page, edits, and re-posts changed content. The wiki breaks pages into
groups and pages (e.g. ThisGroup/ThisPage). The sections that are
camel cased (or otherwise contain title case) are the group and page
for a given page.
Ben> I am working on a script that splits a URL into a page and a
Ben> url.
I couldn't tell quite what you mean to accomplish from your example. (In
particular, I don't know what you mean by "default_group", as it's never
defined, and I don't know why the desired output of examples 1 and
Here is what I came up with:
def siftUrl(s):
s = s.split('//')[1]
bits = s.split('/')
if '' in bits: bits.remove('')
if len(bits) > 1:
group = bits[-2]
page = bits[-1]
group.strip('/')
page.strip('/')
else
I am working on a script that splits a URL into a page and a url. The
examples below are the conditions I expect a user to pass to the
script. In all cases, "http://www.example.org/test/"; is the URL, and
the page comprises parts that have upper case letters (note, 5 & 6 are
the same as earlier exa