src/eric7/Project/Project.py

branch
eric7-maintenance
changeset 9940
a57c188857e9
parent 9832
3885b9d7bd31
parent 9925
a267ac36dd69
child 10004
983477114d3c
equal deleted inserted replaced
9833:9308099b7d38 9940:a57c188857e9
632 else: 632 else:
633 if self.__pdata[dataKey] != data and setDirty: 633 if self.__pdata[dataKey] != data and setDirty:
634 self.setDirty(True) 634 self.setDirty(True)
635 self.__pdata[dataKey] = data 635 self.__pdata[dataKey] = data
636 636
637 def getData(self, category, key): 637 def getData(self, category, key, default=None):
638 """ 638 """
639 Public method to get data out of the project data store. 639 Public method to get data out of the project data store.
640 640
641 @param category category of the data to get (string, one of 641 @param category category of the data to get (one of
642 PROJECTTYPESPECIFICDATA, CHECKERSPARMS, PACKAGERSPARMS, 642 PROJECTTYPESPECIFICDATA, CHECKERSPARMS, PACKAGERSPARMS,
643 DOCUMENTATIONPARMS or OTHERTOOLSPARMS) 643 DOCUMENTATIONPARMS or OTHERTOOLSPARMS)
644 @param key key of the data entry to get (string). 644 @type str
645 @param key key of the data entry to get
646 @type str
647 @param default value to return in case the key is not found (defaults to None)
648 @type Any (optional)
645 @return a copy of the requested data or None 649 @return a copy of the requested data or None
646 """ 650 """
647 # __IGNORE_WARNING_D202__ 651 # __IGNORE_WARNING_D202__
648 if ( 652 if (
649 category 653 category
656 ] 660 ]
657 and key in self.__pdata[category] 661 and key in self.__pdata[category]
658 ): 662 ):
659 return copy.deepcopy(self.__pdata[category][key]) 663 return copy.deepcopy(self.__pdata[category][key])
660 else: 664 else:
661 return None 665 return default
662 666
663 def setData(self, category, key, data): 667 def setData(self, category, key, data):
664 """ 668 """
665 Public method to store data in the project data store. 669 Public method to store data in the project data store.
666 670
3833 3837
3834 @param path file or directory name to convert (string) 3838 @param path file or directory name to convert (string)
3835 @return project relative path or unchanged path, if path doesn't 3839 @return project relative path or unchanged path, if path doesn't
3836 belong to the project (string) 3840 belong to the project (string)
3837 """ 3841 """
3842 if path is None:
3843 return ""
3844
3838 try: 3845 try:
3839 return str(pathlib.Path(path).relative_to(self.ppath)) 3846 return str(pathlib.Path(path).relative_to(self.ppath))
3840 except ValueError: 3847 except ValueError:
3841 return path 3848 return path
3842 3849

eric ide

mercurial