예제 #1
0
    def doExport( self, project ):
        filename = self.savewidget.selectedFile()
        if not filename:
            self.forms.showMessageBox("Sorry", i18n("Error"), i18n("No file selected"))
            return
        schId = self.scheduleview.currentSchedule()
        if schId == -1:
            self.forms.showMessageBox("Sorry", i18n("Error"), i18n("No schedule selected"))
            return
        # cal= Calendar()
        # cal.add('prodid', '-//'+project.id()+'//'+KPlato.data(project, 'NodeName'))
        # cal.add('version', '0.1')
        file = open( filename, 'wb' )
        print("=================== "+str(project.id())+str(KPlato.data(project,'NodeName'))+" ==================",file=file)
        for i in range( project.resourceGroupCount() ):
            g = project.resourceGroupAt( i )
            print (g,file=file)
            for ri in range( g.resourceCount() ):
                r = g.resourceAt( ri )
                print("====> r:\n\t", "\n\t".join( dir(r)),file=file)
                lst = r.appointmentIntervals( schId )
                print("====> lst:\n\t", "\n\t".join(dir(lst)),file=file)
                for iv in lst:
                    print(r.id(), KPlato.data( r, 'ResourceName' ), iv, sep=" | ", file=file)
                    print ("====> iv:\n\t", "\n\t".join( dir(iv)),file=file)
                    # iv.insert( 0, r.id() )
                    # iv.insert( 1, KPlato.data( r, 'ResourceName' ) )
                    # pickle.dump( iv, file )

        file.close()
예제 #2
0
def printState( node, schedule ):
    if node.type() in [ 'Task' ]:
        st = KPlato.data( node, 'NodeStatus', 'EditRole', schedule )
        print "%-30s %-20s %20s" % ( 
            KPlato.data( node, 'NodeName', 'DisplayRole', schedule ),
            KPlato.data( node, 'NodeStatus', 'DisplayRole', schedule ),
            state( int( st ) ) )
예제 #3
0
 def loadAppointment( self, project, pid, pname, data ):
     r = project.findResource( data[0] )
     if r is None:
         print "Resource is not used in this project: %s, %s" % ( data[0], data[1] )
         return
     if KPlato.data( r, 'ResourceName' ) != data[1]:
         #TODO Warning ?
         print "Resources has same id but different names %s - %s" % ( KPlato.data( r, 'ResourceName' ), data[1] )
     r.addExternalAppointment( pid, pname, data[2:5] )
예제 #4
0
def printNode(node, props, schedule, types=None):
    if types is None or node.type() in types:
        for prop in props:
            print "%-25s" % (KPlato.data(node, prop[0], prop[1], schedule)),
        print
        print dir(node)
    else:
        print "missing: ", node.type(), dir(node)
예제 #5
0
 def doImportResource( self, project, group, resource ):
     r = project.findResource( resource.id() )
     if r is None:
         r = project.createResource( group, resource )
         if r is None:
             raise Exception, i18n("Unable to create copy of resource: %1", [resource.name()])
     else:
         #TODO update?
         print "Resource already exists: %s %s" % ( r.id(), KPlato.data( r, 'ResourceName' ) )
예제 #6
0
 def doImportResource( self, project, group, resource ):
     r = project.findResource( resource.id() )
     if r is None:
         r = project.createResource( group, resource )
         if r is None:
             self.forms.showMessageBox("Sorry", i18n("Error"), i18n("Unable to create copy of resource: %1", [resource.name()]))
             return
     else:
         #TODO update?
         print "Resource already exists: %s %s" % ( r.id(), KPlato.data( r, 'ResourceName' ) )
예제 #7
0
 def check(self, project):
     lst = []
     for i in range(project.resourceGroupCount()):
         g = project.resourceGroupAt(i)
         for ri in range(g.resourceCount()):
             r = g.resourceAt(ri)
             lst = r.externalAppointments()
             for iv in lst:
                 iv.insert(0, r.id())
                 iv.insert(1, KPlato.data(r, "ResourceName"))
             print lst
예제 #8
0
    def doExport( self, project ):
        filename = self.savewidget.selectedFile()
        if not filename:
            raise Exception, i18n("No file selected")
        schId = self.scheduleview.currentSchedule()
        if schId == -1:
            raise Exception, i18n("No schedule selected")
        file = open( filename, 'w' )
        p = []
        p.append( project.id() )
        p.append( KPlato.data( project, 'NodeName' ) )
        pickle.dump( p, file )
        for i in range( project.resourceGroupCount() ):
            g = project.resourceGroupAt( i )
            for ri in range( g.resourceCount() ):
                r = g.resourceAt( ri )
                lst = r.appointmentIntervals( schId )
                for iv in lst:
                    iv.insert( 0, r.id() )
                    iv.insert( 1, KPlato.data( r, 'ResourceName' ) )
                    pickle.dump( iv, file )

        file.close()
예제 #9
0
def printResource( resource, props ):
    for prop in props:
        print "%-25s" % ( KPlato.data( resource, prop ) ),
    print
예제 #10
0
def printGroup( group, props ):
    for prop in props:
        print "%-25s" % ( KPlato.data( group, prop ) ),
    print
    for i in range( group.resourceCount() ):
        printResource( group.resourceAt( i ), props )
예제 #11
0
def printNode( node, props, schedule, types = None ):
    if types is None or node.type() in types:
        for prop in props:
            print "%-25s" % ( KPlato.data( node, prop[0], prop[1], schedule ) ),
        print
예제 #12
0
def printBusyinfo( res, lst ):
    name = KPlato.data( res, 'ResourceName' )
    for interval in lst:
        print "%-20s %-30s %-30s %8s" % ( name, interval[0], interval[1], interval[2] )
        name = ""
예제 #13
0
for index in range( proj.resourceGroupCount() ):
    g = proj.resourceGroupAt( index )
    printGroup( g, resprops )

print

print "Print Schedules:"
printSchedules()
print


print "Print Effort/Cost for each node:"
print "%-20s %-10s %-10s %-10s" % ( 'Name', 'Date', 'Effort', 'Cost' )
for i in range( proj.nodeCount() ):
    node = proj.nodeAt( i )
    name = KPlato.data( node, 'NodeName' )
    printEffortCost( name, node.plannedEffortCostPrDay( "2007-09-12", "2007-09-18", sid ) )

print "Print Effort/Cost for the project:"

print "%-20s %-10s %-10s %-10s" % ( 'Name', 'Date', 'Effort', 'Cost' )
name = KPlato.data( proj, 'NodeName' )
printEffortCost( name, proj.plannedEffortCostPrDay( "2007-09-12", "2007-09-17", sid ) )

print "Print Busy information for all resources in the project:"
printProjectBusyinfo( proj )
print

print "Print the calendars in the project:"
printProjectCalendars( proj )
print
예제 #14
0
for mn in dir(KPlato):
    m = getattr(KPlato, mn)
    print mn, "===>", m.__doc__

KPlato.document().openUrl("/home/dimon/work/python/koffice-scripts/kplato/test_project.kplato")
project = KPlato.project()

print dir(KPlato.data)

sid = -1
# get a schedule id
if project.scheduleCount() > 0:
    sched = project.scheduleAt(0)
    sid = sched.id()
    print "appointments?? : ", KPlato.data(sched, "m_appointments")

print project.id(), KPlato.data(project, "NodeName")

printSchedules(project)

nodeprops = [
    ["NodeWBSCode", "DisplayRole"],
    ["NodeName", "DisplayRole"],
    ["NodeType", "DisplayRole"],
    ["NodeAssignments", "DisplayRole"],
    ["NodeStatus", "EditRole"],
]
print "Print tasks and milestones in arbitrary order:"
# print the localized headers
for prop in nodeprops:
예제 #15
0
def printNode( node, props, types = None ):
    if types is None or node.type() in types:
        for prop in props:
            print "%-25s" % ( KPlato.data( node, prop ) ),
        print
예제 #16
0
 def printNode( node, props, schedule, types = None ):
     s=''
     if types is None or node.type() in types:
         for prop in props:
             s=s+"%-25s" % ( KPlato.data( node, prop[0], prop[1], schedule ) )
     return s