Trouble with win32com and MS Project

2005-10-19 Thread Felix Collins
Hi,

I'm trying to assign a resource to a task in MS Project by using the 
example from MSDN for VB...


"Use the Add method to add an Assignment object to the Assignments 
collection. The following example adds a resource identified by the 
number of 212 as a new assignment for the specified task.

ActiveProject.Tasks(1).Assignments.Add ResourceID:=212"

My code fragment for Python...

proj.Tasks(3).Assignments.Add(ResourceID=2)

but this doesn't work.  I get...

Error (-2147352567, 'Exception occurred.', (0, None, 'The argument value 
is not valid.', 'D:\\Program Files\\Microsoft 
Office\\OFFICE11\\VBAPJ.CHM', 131074, -2146827187), None)


Anyone got any ideas about how to attack this?

Cheers,
Felix
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Trouble with win32com and MS Project

2005-10-19 Thread Felix Collins
Felix Collins wrote:
> Hi,
> 
> I'm trying to assign a resource to a task in MS Project by using the 
> example from MSDN for VB...
> 
> 
> "Use the Add method to add an Assignment object to the Assignments 
> collection. The following example adds a resource identified by the 
> number of 212 as a new assignment for the specified task.
> 
> ActiveProject.Tasks(1).Assignments.Add ResourceID:=212"
> 
> My code fragment for Python...
> 
> proj.Tasks(3).Assignments.Add(ResourceID=2)

I managed to get this to work by providing the TaskID which is supposed 
to be an optional argument.  I wonder if the win32com wrapper is 
stuffing this up.  Is late binding responsible perhaps?

So the code that works is...

proj.Tasks(3).Assignments.Add(TaskID= 3,ResourceID=2)

incidently this also works...

proj.Tasks(3).Assignments.Add(TaskID= 5,ResourceID=2)

which does seems a bit strange
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with regexp please

2005-07-22 Thread Felix Collins
Christopher Subich wrote:
> Scott David Daniels wrote:
Thanks to you both.  Wow!  what a quick response!

 >string.rsplit('.',1)[0]

Clever Python!  ;-)


Sorry, I mainly code in C so I'm not very Pythonic in my thinking.
Thanks again...

Felix
-- 
http://mail.python.org/mailman/listinfo/python-list


Help with regexp please

2005-07-22 Thread Felix Collins
Hi,
  I'm not a regexp expert and had a bit of trouble with the following 
search.

I have an "outline number" system like

1
1.2
1.2.3
1.3
2
3
3.1

etc.

I want to parse an outline number and return the parent.

So for example...

parent("1.2.3.4") returns "1.2.3"

The only way I can figure is to do two searches feeding the output of 
the first into the input of the second.

Here is the code fragment...

m = re.compile(r'(\d+\.)+').match("1.2.3.4")
n = re.compile(r'\d+(\.\d+)+').match(m.string[m.start():m.end()])
parentoutlinenumber = n.string[n.start():n.end()]

parentoutlinenumber
1.2.3

How do I get that into one regexp?

Thanks for any help...

Felix
-- 
http://mail.python.org/mailman/listinfo/python-list


HELP:sorting list of outline numbers

2005-08-02 Thread Felix Collins
Hi All,
does anyone know any cleaver tricks to sort a list of outline numbers.

An outline number is a number of the form...1.2.3

they should be sorted in the following way...

1
1.1
1.2
1.12

python's alpha sort (by design) sorts them...

1
1.1
1.12
1.2

That's no good for me.
I'm planning on splitting the strings into multiple lists of ints and 
doing numerical sorts.

Thanks for any clever ideas that might make it easier.

Felix
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HELP:sorting list of outline numbers

2005-08-02 Thread Felix Collins
Robert Kern wrote:
> Felix Collins wrote:
> 
> Use the "key" keyword argument to list.sort().
> 
> In [1]: outline = ['1.12', '1.1', '1', '1.2']
> 
> In [2]: outline.sort(key=lambda x: map(int, x.split('.')))
> 
> In [3]: outline
> Out[3]: ['1', '1.1', '1.2', '1.12']
> 


Is this new in 2.4?  I have to use 2.3 as I'm working with Trac.

Traceback (most recent call last):
   File "", line 1, in -toplevel-
 keys.sort(key=lambda x: map(int, x.split('.')))
TypeError: sort() takes no keyword arguments


Thanks Scott and Robert for your quick help.  This list is amazing!

Regards,
Felix
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HELP:sorting list of outline numbers

2005-08-02 Thread Felix Collins
Felix Collins wrote:
> 
> Thanks Scott and Robert for your quick help.  This list is amazing!
> 
> Regards,
> Felix

Using Decorate, Sort , Undecorate...

works like a charm.

Thanks again.

Felix
-- 
http://mail.python.org/mailman/listinfo/python-list