"David" wrote
I don't know how else to describe it, that is so cool :)
:-)
Couple of comments below.
import textwrap
data = {'CBUILD':None, 'CFLAGS':None, 'MAKEOPTS':None}
def get_use():
fname = open('/tmp/comprookie2000/emerge_info.txt')
for line in fname:
for keyphrase
Alan Gauld wrote:
"Sander Sweers" wrote
What you can do is define all the variables upfront. This way you can
get rid of the else. Below is an example how you can do this with only
looping once over the fle.
And you can put the variables as keys of a dictionary and avoid all the
if tests:
"Sander Sweers" wrote
What you can do is define all the variables upfront. This way you can
get rid of the else. Below is an example how you can do this with only
looping once over the fle.
And you can put the variables as keys of a dictionary and avoid
all the if tests:
data = {'CBUILD':
Sander Sweers wrote:
> 2009/4/29 David :
>> Here is the whole program so far, what it does is it logs into a druple web
>> site and posts. I would like to make it better, as you can see I do the same
>> thing over and over.
>>
>> http://linuxcrazy.pastebin.com/m7689c088
>
> What you can do is defi
David wrote:
> Martin Walsh wrote:
>>> ... but, you don't need to use subprocess at all. How about (untested),
>>>
>>> # grep USE /tmp/comprookie2000/emerge_info.txt |head -n1|cut -d\" -f2
>>> infof = open('/tmp/comprookie2000/emerge_info.txt')
>>> for line in infof:
>>> if 'USE' in line:
>>>
2009/4/29 David :
> Here is the whole program so far, what it does is it logs into a druple web
> site and posts. I would like to make it better, as you can see I do the same
> thing over and over.
>
> http://linuxcrazy.pastebin.com/m7689c088
What you can do is define all the variables upfront. Th
David wrote:
Martin Walsh wrote:
Just one more comment, string.join is deprecated, yet join is a method
of str objects. So ...
Lines = '\n'.join(L)
... or use textwrap.fill which returns a string with the newlines
already in place ...
Lines = textwrap.fill(USE, 80)
HTH,
Marty
Martin Walsh wrote:
... but, you don't need to use subprocess at all. How about (untested),
# grep USE /tmp/comprookie2000/emerge_info.txt |head -n1|cut -d\" -f2
infof = open('/tmp/comprookie2000/emerge_info.txt')
for line in infof:
if 'USE' in line:
USE = line.split('"')[1]
David wrote:
I am getting information from .txt files and posting them in fields on a
web site. I need to break up single strings so they are around 80
characters then a new line because when I enter the info to the form on
the website it has fields and it errors out with such a long string.
David wrote:
> vince spicer wrote:
>> first, grabbing output from an external command try:
>>
>> import commands
>>
>> USE = commands.getoutput('grep USE /tmp/comprookie2000/emege_info.txt
>> |head -n1|cut -d\\"-f2')
>>
>> then you can wrap strings,
>>
>> import textwrap
>>
>> Lines = textwrap.wr
David wrote:
> I am getting information from .txt files and posting them in fields on a
> web site. I need to break up single strings so they are around 80
> characters then a new line because when I enter the info to the form on
> the website it has fields and it errors out with such a long string
vince spicer wrote:
first, grabbing output from an external command try:
import commands
USE = commands.getoutput('grep USE /tmp/comprookie2000/emege_info.txt
|head -n1|cut -d\\"-f2')
then you can wrap strings,
import textwrap
Lines = textwrap.wrap(USE, 80) # return a list
so in short:
first, grabbing output from an external command try:
import commands
USE = commands.getoutput('grep USE /tmp/comprookie2000/emege_info.txt |head
-n1|cut -d\\"-f2')
then you can wrap strings,
import textwrap
Lines = textwrap.wrap(USE, 80) # return a list
so in short:
import commands, textwrap
I am getting information from .txt files and posting them in fields on a
web site. I need to break up single strings so they are around 80
characters then a new line because when I enter the info to the form on
the website it has fields and it errors out with such a long string.
here is a samp
14 matches
Mail list logo