2 Commits 3187cbf871 ... f6f93b3e07

Author SHA1 Message Date
  Michael Buesch f6f93b3e07 project: Add method to get all sources 6 years ago
  Michael Buesch 5906565f42 sources: Add copyFrom method 6 years ago
2 changed files with 25 additions and 7 deletions
  1. 7 0
      awlsim/common/project.py
  2. 18 7
      awlsim/common/sources.py

+ 7 - 0
awlsim/common/project.py

@@ -876,6 +876,13 @@ class Project(object):
 	def getSymTabSources(self):
 		return self.symTabSources
 
+	def getAllSources(self):
+		for source in itertools.chain(self.getAwlSources(),
+					      self.getFupSources(),
+					      self.getKopSources(),
+					      self.getSymTabSources()):
+			yield source
+
 	def setLibSelections(self, libSelections):
 		self.libSelections = libSelections or []
 

+ 18 - 7
awlsim/common/sources.py

@@ -271,13 +271,6 @@ class GenericSource(object):
 	def identHashStr(self):
 		return bytesToHexStr(self.identHash)
 
-	def dup(self):
-		return self.__class__(name=self.name,
-				      enabled=self.enabled,
-				      filepath=self.filepath,
-				      sourceBytes=self.sourceBytes[:],
-				      userData=self.userData)
-
 	def isFileBacked(self):
 		return bool(self.filepath)
 
@@ -333,6 +326,24 @@ class GenericSource(object):
 			   filepath=None,
 			   sourceBytes=data)
 
+	def dup(self):
+		"""Duplicate this source. Returns a copy.
+		"""
+		return self.__class__(name=self.name,
+				      enabled=self.enabled,
+				      filepath=self.filepath,
+				      sourceBytes=self.sourceBytes[:],
+				      userData=self.userData)
+
+	def copyFrom(self, other):
+		"""Copy the content of another source into this one.
+		"""
+		self.name = other.name
+		self.enabled = other.enabled
+		self.filepath = other.filepath
+		self.sourceBytes = other.sourceBytes[:]
+		self.userData = other.userData.copy()
+
 	def __eq__(self, other):
 		return self.identHash == other.identHash