id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
18,200
noxdafox/clipspy
clips/facts.py
Facts.load_facts
def load_facts(self, facts): """Load a set of facts into the CLIPS data base. The C equivalent of the CLIPS load-facts command. Facts can be loaded from a string or from a text file. """ facts = facts.encode() if os.path.exists(facts): ret = lib.EnvLoadFacts(self._env, facts) if ret == -1: raise CLIPSError(self._env) else: ret = lib.EnvLoadFactsFromString(self._env, facts, -1) if ret == -1: raise CLIPSError(self._env) return ret
python
def load_facts(self, facts): facts = facts.encode() if os.path.exists(facts): ret = lib.EnvLoadFacts(self._env, facts) if ret == -1: raise CLIPSError(self._env) else: ret = lib.EnvLoadFactsFromString(self._env, facts, -1) if ret == -1: raise CLIPSError(self._env) return ret
[ "def", "load_facts", "(", "self", ",", "facts", ")", ":", "facts", "=", "facts", ".", "encode", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "facts", ")", ":", "ret", "=", "lib", ".", "EnvLoadFacts", "(", "self", ".", "_env", ",", "fact...
Load a set of facts into the CLIPS data base. The C equivalent of the CLIPS load-facts command. Facts can be loaded from a string or from a text file.
[ "Load", "a", "set", "of", "facts", "into", "the", "CLIPS", "data", "base", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L102-L121
18,201
noxdafox/clipspy
clips/facts.py
Facts.save_facts
def save_facts(self, path, mode=SaveMode.LOCAL_SAVE): """Save the facts in the system to the specified file. The Python equivalent of the CLIPS save-facts command. """ ret = lib.EnvSaveFacts(self._env, path.encode(), mode) if ret == -1: raise CLIPSError(self._env) return ret
python
def save_facts(self, path, mode=SaveMode.LOCAL_SAVE): ret = lib.EnvSaveFacts(self._env, path.encode(), mode) if ret == -1: raise CLIPSError(self._env) return ret
[ "def", "save_facts", "(", "self", ",", "path", ",", "mode", "=", "SaveMode", ".", "LOCAL_SAVE", ")", ":", "ret", "=", "lib", ".", "EnvSaveFacts", "(", "self", ".", "_env", ",", "path", ".", "encode", "(", ")", ",", "mode", ")", "if", "ret", "==", ...
Save the facts in the system to the specified file. The Python equivalent of the CLIPS save-facts command.
[ "Save", "the", "facts", "in", "the", "system", "to", "the", "specified", "file", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L123-L133
18,202
noxdafox/clipspy
clips/facts.py
Fact.asserted
def asserted(self): """True if the fact has been asserted within CLIPS.""" # https://sourceforge.net/p/clipsrules/discussion/776945/thread/4f04bb9e/ if self.index == 0: return False return bool(lib.EnvFactExistp(self._env, self._fact))
python
def asserted(self): # https://sourceforge.net/p/clipsrules/discussion/776945/thread/4f04bb9e/ if self.index == 0: return False return bool(lib.EnvFactExistp(self._env, self._fact))
[ "def", "asserted", "(", "self", ")", ":", "# https://sourceforge.net/p/clipsrules/discussion/776945/thread/4f04bb9e/", "if", "self", ".", "index", "==", "0", ":", "return", "False", "return", "bool", "(", "lib", ".", "EnvFactExistp", "(", "self", ".", "_env", ",",...
True if the fact has been asserted within CLIPS.
[ "True", "if", "the", "fact", "has", "been", "asserted", "within", "CLIPS", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L173-L179
18,203
noxdafox/clipspy
clips/facts.py
Fact.template
def template(self): """The associated Template.""" return Template( self._env, lib.EnvFactDeftemplate(self._env, self._fact))
python
def template(self): return Template( self._env, lib.EnvFactDeftemplate(self._env, self._fact))
[ "def", "template", "(", "self", ")", ":", "return", "Template", "(", "self", ".", "_env", ",", "lib", ".", "EnvFactDeftemplate", "(", "self", ".", "_env", ",", "self", ".", "_fact", ")", ")" ]
The associated Template.
[ "The", "associated", "Template", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L182-L185
18,204
noxdafox/clipspy
clips/facts.py
Fact.assertit
def assertit(self): """Assert the fact within the CLIPS environment.""" if self.asserted: raise RuntimeError("Fact already asserted") lib.EnvAssignFactSlotDefaults(self._env, self._fact) if lib.EnvAssert(self._env, self._fact) == ffi.NULL: raise CLIPSError(self._env)
python
def assertit(self): if self.asserted: raise RuntimeError("Fact already asserted") lib.EnvAssignFactSlotDefaults(self._env, self._fact) if lib.EnvAssert(self._env, self._fact) == ffi.NULL: raise CLIPSError(self._env)
[ "def", "assertit", "(", "self", ")", ":", "if", "self", ".", "asserted", ":", "raise", "RuntimeError", "(", "\"Fact already asserted\"", ")", "lib", ".", "EnvAssignFactSlotDefaults", "(", "self", ".", "_env", ",", "self", ".", "_fact", ")", "if", "lib", "....
Assert the fact within the CLIPS environment.
[ "Assert", "the", "fact", "within", "the", "CLIPS", "environment", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L187-L195
18,205
noxdafox/clipspy
clips/facts.py
Fact.retract
def retract(self): """Retract the fact from the CLIPS environment.""" if lib.EnvRetract(self._env, self._fact) != 1: raise CLIPSError(self._env)
python
def retract(self): if lib.EnvRetract(self._env, self._fact) != 1: raise CLIPSError(self._env)
[ "def", "retract", "(", "self", ")", ":", "if", "lib", ".", "EnvRetract", "(", "self", ".", "_env", ",", "self", ".", "_fact", ")", "!=", "1", ":", "raise", "CLIPSError", "(", "self", ".", "_env", ")" ]
Retract the fact from the CLIPS environment.
[ "Retract", "the", "fact", "from", "the", "CLIPS", "environment", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L197-L200
18,206
noxdafox/clipspy
clips/facts.py
ImpliedFact.append
def append(self, value): """Append an element to the fact.""" if self.asserted: raise RuntimeError("Fact already asserted") self._multifield.append(value)
python
def append(self, value): if self.asserted: raise RuntimeError("Fact already asserted") self._multifield.append(value)
[ "def", "append", "(", "self", ",", "value", ")", ":", "if", "self", ".", "asserted", ":", "raise", "RuntimeError", "(", "\"Fact already asserted\"", ")", "self", ".", "_multifield", ".", "append", "(", "value", ")" ]
Append an element to the fact.
[ "Append", "an", "element", "to", "the", "fact", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L224-L229
18,207
noxdafox/clipspy
clips/facts.py
ImpliedFact.extend
def extend(self, values): """Append multiple elements to the fact.""" if self.asserted: raise RuntimeError("Fact already asserted") self._multifield.extend(values)
python
def extend(self, values): if self.asserted: raise RuntimeError("Fact already asserted") self._multifield.extend(values)
[ "def", "extend", "(", "self", ",", "values", ")", ":", "if", "self", ".", "asserted", ":", "raise", "RuntimeError", "(", "\"Fact already asserted\"", ")", "self", ".", "_multifield", ".", "extend", "(", "values", ")" ]
Append multiple elements to the fact.
[ "Append", "multiple", "elements", "to", "the", "fact", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L231-L236
18,208
noxdafox/clipspy
clips/facts.py
ImpliedFact.assertit
def assertit(self): """Assert the fact within CLIPS.""" data = clips.data.DataObject(self._env) data.value = list(self._multifield) if lib.EnvPutFactSlot( self._env, self._fact, ffi.NULL, data.byref) != 1: raise CLIPSError(self._env) super(ImpliedFact, self).assertit()
python
def assertit(self): data = clips.data.DataObject(self._env) data.value = list(self._multifield) if lib.EnvPutFactSlot( self._env, self._fact, ffi.NULL, data.byref) != 1: raise CLIPSError(self._env) super(ImpliedFact, self).assertit()
[ "def", "assertit", "(", "self", ")", ":", "data", "=", "clips", ".", "data", ".", "DataObject", "(", "self", ".", "_env", ")", "data", ".", "value", "=", "list", "(", "self", ".", "_multifield", ")", "if", "lib", ".", "EnvPutFactSlot", "(", "self", ...
Assert the fact within CLIPS.
[ "Assert", "the", "fact", "within", "CLIPS", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L238-L247
18,209
noxdafox/clipspy
clips/facts.py
TemplateFact.update
def update(self, sequence=None, **mapping): """Add multiple elements to the fact.""" if sequence is not None: if isinstance(sequence, dict): for slot in sequence: self[slot] = sequence[slot] else: for slot, value in sequence: self[slot] = value if mapping: for slot in sequence: self[slot] = sequence[slot]
python
def update(self, sequence=None, **mapping): if sequence is not None: if isinstance(sequence, dict): for slot in sequence: self[slot] = sequence[slot] else: for slot, value in sequence: self[slot] = value if mapping: for slot in sequence: self[slot] = sequence[slot]
[ "def", "update", "(", "self", ",", "sequence", "=", "None", ",", "*", "*", "mapping", ")", ":", "if", "sequence", "is", "not", "None", ":", "if", "isinstance", "(", "sequence", ",", "dict", ")", ":", "for", "slot", "in", "sequence", ":", "self", "[...
Add multiple elements to the fact.
[ "Add", "multiple", "elements", "to", "the", "fact", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L289-L300
18,210
noxdafox/clipspy
clips/facts.py
Template.name
def name(self): """Template name.""" return ffi.string( lib.EnvGetDeftemplateName(self._env, self._tpl)).decode()
python
def name(self): return ffi.string( lib.EnvGetDeftemplateName(self._env, self._tpl)).decode()
[ "def", "name", "(", "self", ")", ":", "return", "ffi", ".", "string", "(", "lib", ".", "EnvGetDeftemplateName", "(", "self", ".", "_env", ",", "self", ".", "_tpl", ")", ")", ".", "decode", "(", ")" ]
Template name.
[ "Template", "name", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L337-L340
18,211
noxdafox/clipspy
clips/facts.py
Template.module
def module(self): """The module in which the Template is defined. Python equivalent of the CLIPS deftemplate-module command. """ modname = ffi.string(lib.EnvDeftemplateModule(self._env, self._tpl)) defmodule = lib.EnvFindDefmodule(self._env, modname) return Module(self._env, defmodule)
python
def module(self): modname = ffi.string(lib.EnvDeftemplateModule(self._env, self._tpl)) defmodule = lib.EnvFindDefmodule(self._env, modname) return Module(self._env, defmodule)
[ "def", "module", "(", "self", ")", ":", "modname", "=", "ffi", ".", "string", "(", "lib", ".", "EnvDeftemplateModule", "(", "self", ".", "_env", ",", "self", ".", "_tpl", ")", ")", "defmodule", "=", "lib", ".", "EnvFindDefmodule", "(", "self", ".", "...
The module in which the Template is defined. Python equivalent of the CLIPS deftemplate-module command.
[ "The", "module", "in", "which", "the", "Template", "is", "defined", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L343-L352
18,212
noxdafox/clipspy
clips/facts.py
Template.watch
def watch(self, flag): """Whether or not the Template is being watched.""" lib.EnvSetDeftemplateWatch(self._env, int(flag), self._tpl)
python
def watch(self, flag): lib.EnvSetDeftemplateWatch(self._env, int(flag), self._tpl)
[ "def", "watch", "(", "self", ",", "flag", ")", ":", "lib", ".", "EnvSetDeftemplateWatch", "(", "self", ".", "_env", ",", "int", "(", "flag", ")", ",", "self", ".", "_tpl", ")" ]
Whether or not the Template is being watched.
[ "Whether", "or", "not", "the", "Template", "is", "being", "watched", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L365-L367
18,213
noxdafox/clipspy
clips/facts.py
Template.slots
def slots(self): """Iterate over the Slots of the Template.""" if self.implied: return () data = clips.data.DataObject(self._env) lib.EnvDeftemplateSlotNames(self._env, self._tpl, data.byref) return tuple( TemplateSlot(self._env, self._tpl, n.encode()) for n in data.value)
python
def slots(self): if self.implied: return () data = clips.data.DataObject(self._env) lib.EnvDeftemplateSlotNames(self._env, self._tpl, data.byref) return tuple( TemplateSlot(self._env, self._tpl, n.encode()) for n in data.value)
[ "def", "slots", "(", "self", ")", ":", "if", "self", ".", "implied", ":", "return", "(", ")", "data", "=", "clips", ".", "data", ".", "DataObject", "(", "self", ".", "_env", ")", "lib", ".", "EnvDeftemplateSlotNames", "(", "self", ".", "_env", ",", ...
Iterate over the Slots of the Template.
[ "Iterate", "over", "the", "Slots", "of", "the", "Template", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L374-L384
18,214
noxdafox/clipspy
clips/facts.py
Template.new_fact
def new_fact(self): """Create a new Fact from this template.""" fact = lib.EnvCreateFact(self._env, self._tpl) if fact == ffi.NULL: raise CLIPSError(self._env) return new_fact(self._env, fact)
python
def new_fact(self): fact = lib.EnvCreateFact(self._env, self._tpl) if fact == ffi.NULL: raise CLIPSError(self._env) return new_fact(self._env, fact)
[ "def", "new_fact", "(", "self", ")", ":", "fact", "=", "lib", ".", "EnvCreateFact", "(", "self", ".", "_env", ",", "self", ".", "_tpl", ")", "if", "fact", "==", "ffi", ".", "NULL", ":", "raise", "CLIPSError", "(", "self", ".", "_env", ")", "return"...
Create a new Fact from this template.
[ "Create", "a", "new", "Fact", "from", "this", "template", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L386-L392
18,215
noxdafox/clipspy
clips/facts.py
Template.undefine
def undefine(self): """Undefine the Template. Python equivalent of the CLIPS undeftemplate command. The object becomes unusable after this method has been called. """ if lib.EnvUndeftemplate(self._env, self._tpl) != 1: raise CLIPSError(self._env)
python
def undefine(self): if lib.EnvUndeftemplate(self._env, self._tpl) != 1: raise CLIPSError(self._env)
[ "def", "undefine", "(", "self", ")", ":", "if", "lib", ".", "EnvUndeftemplate", "(", "self", ".", "_env", ",", "self", ".", "_tpl", ")", "!=", "1", ":", "raise", "CLIPSError", "(", "self", ".", "_env", ")" ]
Undefine the Template. Python equivalent of the CLIPS undeftemplate command. The object becomes unusable after this method has been called.
[ "Undefine", "the", "Template", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L394-L403
18,216
noxdafox/clipspy
clips/facts.py
TemplateSlot.multifield
def multifield(self): """True if the slot is a multifield slot.""" return bool(lib.EnvDeftemplateSlotMultiP( self._env, self._tpl, self._name))
python
def multifield(self): return bool(lib.EnvDeftemplateSlotMultiP( self._env, self._tpl, self._name))
[ "def", "multifield", "(", "self", ")", ":", "return", "bool", "(", "lib", ".", "EnvDeftemplateSlotMultiP", "(", "self", ".", "_env", ",", "self", ".", "_tpl", ",", "self", ".", "_name", ")", ")" ]
True if the slot is a multifield slot.
[ "True", "if", "the", "slot", "is", "a", "multifield", "slot", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L438-L441
18,217
noxdafox/clipspy
clips/facts.py
TemplateSlot.default_type
def default_type(self): """The default value type for this Slot. The Python equivalent of the CLIPS deftemplate-slot-defaultp function. """ return TemplateSlotDefaultType( lib.EnvDeftemplateSlotDefaultP(self._env, self._tpl, self._name))
python
def default_type(self): return TemplateSlotDefaultType( lib.EnvDeftemplateSlotDefaultP(self._env, self._tpl, self._name))
[ "def", "default_type", "(", "self", ")", ":", "return", "TemplateSlotDefaultType", "(", "lib", ".", "EnvDeftemplateSlotDefaultP", "(", "self", ".", "_env", ",", "self", ".", "_tpl", ",", "self", ".", "_name", ")", ")" ]
The default value type for this Slot. The Python equivalent of the CLIPS deftemplate-slot-defaultp function.
[ "The", "default", "value", "type", "for", "this", "Slot", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/facts.py#L487-L494
18,218
noxdafox/clipspy
clips/classes.py
Classes.instances_changed
def instances_changed(self): """True if any instance has changed.""" value = bool(lib.EnvGetInstancesChanged(self._env)) lib.EnvSetInstancesChanged(self._env, int(False)) return value
python
def instances_changed(self): value = bool(lib.EnvGetInstancesChanged(self._env)) lib.EnvSetInstancesChanged(self._env, int(False)) return value
[ "def", "instances_changed", "(", "self", ")", ":", "value", "=", "bool", "(", "lib", ".", "EnvGetInstancesChanged", "(", "self", ".", "_env", ")", ")", "lib", ".", "EnvSetInstancesChanged", "(", "self", ".", "_env", ",", "int", "(", "False", ")", ")", ...
True if any instance has changed.
[ "True", "if", "any", "instance", "has", "changed", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L84-L89
18,219
noxdafox/clipspy
clips/classes.py
Classes.classes
def classes(self): """Iterate over the defined Classes.""" defclass = lib.EnvGetNextDefclass(self._env, ffi.NULL) while defclass != ffi.NULL: yield Class(self._env, defclass) defclass = lib.EnvGetNextDefclass(self._env, defclass)
python
def classes(self): defclass = lib.EnvGetNextDefclass(self._env, ffi.NULL) while defclass != ffi.NULL: yield Class(self._env, defclass) defclass = lib.EnvGetNextDefclass(self._env, defclass)
[ "def", "classes", "(", "self", ")", ":", "defclass", "=", "lib", ".", "EnvGetNextDefclass", "(", "self", ".", "_env", ",", "ffi", ".", "NULL", ")", "while", "defclass", "!=", "ffi", ".", "NULL", ":", "yield", "Class", "(", "self", ".", "_env", ",", ...
Iterate over the defined Classes.
[ "Iterate", "over", "the", "defined", "Classes", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L91-L98
18,220
noxdafox/clipspy
clips/classes.py
Classes.find_class
def find_class(self, name): """Find the Class by its name.""" defclass = lib.EnvFindDefclass(self._env, name.encode()) if defclass == ffi.NULL: raise LookupError("Class '%s' not found" % name) return Class(self._env, defclass)
python
def find_class(self, name): defclass = lib.EnvFindDefclass(self._env, name.encode()) if defclass == ffi.NULL: raise LookupError("Class '%s' not found" % name) return Class(self._env, defclass)
[ "def", "find_class", "(", "self", ",", "name", ")", ":", "defclass", "=", "lib", ".", "EnvFindDefclass", "(", "self", ".", "_env", ",", "name", ".", "encode", "(", ")", ")", "if", "defclass", "==", "ffi", ".", "NULL", ":", "raise", "LookupError", "("...
Find the Class by its name.
[ "Find", "the", "Class", "by", "its", "name", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L100-L106
18,221
noxdafox/clipspy
clips/classes.py
Classes.instances
def instances(self): """Iterate over the defined Instancees.""" definstance = lib.EnvGetNextInstance(self._env, ffi.NULL) while definstance != ffi.NULL: yield Instance(self._env, definstance) definstance = lib.EnvGetNextInstance(self._env, definstance)
python
def instances(self): definstance = lib.EnvGetNextInstance(self._env, ffi.NULL) while definstance != ffi.NULL: yield Instance(self._env, definstance) definstance = lib.EnvGetNextInstance(self._env, definstance)
[ "def", "instances", "(", "self", ")", ":", "definstance", "=", "lib", ".", "EnvGetNextInstance", "(", "self", ".", "_env", ",", "ffi", ".", "NULL", ")", "while", "definstance", "!=", "ffi", ".", "NULL", ":", "yield", "Instance", "(", "self", ".", "_env...
Iterate over the defined Instancees.
[ "Iterate", "over", "the", "defined", "Instancees", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L108-L115
18,222
noxdafox/clipspy
clips/classes.py
Classes.find_instance
def find_instance(self, name, module=None): """Find the Instance by its name.""" module = module if module is not None else ffi.NULL definstance = lib.EnvFindInstance(self._env, module, name.encode(), 1) if definstance == ffi.NULL: raise LookupError("Instance '%s' not found" % name) return Instance(self._env, definstance)
python
def find_instance(self, name, module=None): module = module if module is not None else ffi.NULL definstance = lib.EnvFindInstance(self._env, module, name.encode(), 1) if definstance == ffi.NULL: raise LookupError("Instance '%s' not found" % name) return Instance(self._env, definstance)
[ "def", "find_instance", "(", "self", ",", "name", ",", "module", "=", "None", ")", ":", "module", "=", "module", "if", "module", "is", "not", "None", "else", "ffi", ".", "NULL", "definstance", "=", "lib", ".", "EnvFindInstance", "(", "self", ".", "_env...
Find the Instance by its name.
[ "Find", "the", "Instance", "by", "its", "name", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L117-L124
18,223
noxdafox/clipspy
clips/classes.py
Classes.load_instances
def load_instances(self, instances): """Load a set of instances into the CLIPS data base. The C equivalent of the CLIPS load-instances command. Instances can be loaded from a string, from a file or from a binary file. """ instances = instances.encode() if os.path.exists(instances): try: return self._load_instances_binary(instances) except CLIPSError: return self._load_instances_text(instances) else: return self._load_instances_string(instances)
python
def load_instances(self, instances): instances = instances.encode() if os.path.exists(instances): try: return self._load_instances_binary(instances) except CLIPSError: return self._load_instances_text(instances) else: return self._load_instances_string(instances)
[ "def", "load_instances", "(", "self", ",", "instances", ")", ":", "instances", "=", "instances", ".", "encode", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "instances", ")", ":", "try", ":", "return", "self", ".", "_load_instances_binary", "("...
Load a set of instances into the CLIPS data base. The C equivalent of the CLIPS load-instances command. Instances can be loaded from a string, from a file or from a binary file.
[ "Load", "a", "set", "of", "instances", "into", "the", "CLIPS", "data", "base", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L126-L143
18,224
noxdafox/clipspy
clips/classes.py
Classes.restore_instances
def restore_instances(self, instances): """Restore a set of instances into the CLIPS data base. The Python equivalent of the CLIPS restore-instances command. Instances can be passed as a set of strings or as a file. """ instances = instances.encode() if os.path.exists(instances): ret = lib.EnvRestoreInstances(self._env, instances) if ret == -1: raise CLIPSError(self._env) else: ret = lib.EnvRestoreInstancesFromString(self._env, instances, -1) if ret == -1: raise CLIPSError(self._env) return ret
python
def restore_instances(self, instances): instances = instances.encode() if os.path.exists(instances): ret = lib.EnvRestoreInstances(self._env, instances) if ret == -1: raise CLIPSError(self._env) else: ret = lib.EnvRestoreInstancesFromString(self._env, instances, -1) if ret == -1: raise CLIPSError(self._env) return ret
[ "def", "restore_instances", "(", "self", ",", "instances", ")", ":", "instances", "=", "instances", ".", "encode", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "instances", ")", ":", "ret", "=", "lib", ".", "EnvRestoreInstances", "(", "self", ...
Restore a set of instances into the CLIPS data base. The Python equivalent of the CLIPS restore-instances command. Instances can be passed as a set of strings or as a file.
[ "Restore", "a", "set", "of", "instances", "into", "the", "CLIPS", "data", "base", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L166-L185
18,225
noxdafox/clipspy
clips/classes.py
Classes.save_instances
def save_instances(self, path, binary=False, mode=SaveMode.LOCAL_SAVE): """Save the instances in the system to the specified file. If binary is True, the instances will be saved in binary format. The Python equivalent of the CLIPS save-instances command. """ if binary: ret = lib.EnvBinarySaveInstances(self._env, path.encode(), mode) else: ret = lib.EnvSaveInstances(self._env, path.encode(), mode) if ret == 0: raise CLIPSError(self._env) return ret
python
def save_instances(self, path, binary=False, mode=SaveMode.LOCAL_SAVE): if binary: ret = lib.EnvBinarySaveInstances(self._env, path.encode(), mode) else: ret = lib.EnvSaveInstances(self._env, path.encode(), mode) if ret == 0: raise CLIPSError(self._env) return ret
[ "def", "save_instances", "(", "self", ",", "path", ",", "binary", "=", "False", ",", "mode", "=", "SaveMode", ".", "LOCAL_SAVE", ")", ":", "if", "binary", ":", "ret", "=", "lib", ".", "EnvBinarySaveInstances", "(", "self", ".", "_env", ",", "path", "."...
Save the instances in the system to the specified file. If binary is True, the instances will be saved in binary format. The Python equivalent of the CLIPS save-instances command.
[ "Save", "the", "instances", "in", "the", "system", "to", "the", "specified", "file", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L187-L202
18,226
noxdafox/clipspy
clips/classes.py
Classes.make_instance
def make_instance(self, command): """Create and initialize an instance of a user-defined class. command must be a string in the form: (<instance-name> of <class-name> <slot-override>*) <slot-override> :== (<slot-name> <constant>*) Python equivalent of the CLIPS make-instance command. """ ist = lib.EnvMakeInstance(self._env, command.encode()) if ist == ffi.NULL: raise CLIPSError(self._env) return Instance(self._env, ist)
python
def make_instance(self, command): ist = lib.EnvMakeInstance(self._env, command.encode()) if ist == ffi.NULL: raise CLIPSError(self._env) return Instance(self._env, ist)
[ "def", "make_instance", "(", "self", ",", "command", ")", ":", "ist", "=", "lib", ".", "EnvMakeInstance", "(", "self", ".", "_env", ",", "command", ".", "encode", "(", ")", ")", "if", "ist", "==", "ffi", ".", "NULL", ":", "raise", "CLIPSError", "(", ...
Create and initialize an instance of a user-defined class. command must be a string in the form: (<instance-name> of <class-name> <slot-override>*) <slot-override> :== (<slot-name> <constant>*) Python equivalent of the CLIPS make-instance command.
[ "Create", "and", "initialize", "an", "instance", "of", "a", "user", "-", "defined", "class", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L204-L219
18,227
noxdafox/clipspy
clips/classes.py
Class.name
def name(self): """Class name.""" return ffi.string(lib.EnvGetDefclassName(self._env, self._cls)).decode()
python
def name(self): return ffi.string(lib.EnvGetDefclassName(self._env, self._cls)).decode()
[ "def", "name", "(", "self", ")", ":", "return", "ffi", ".", "string", "(", "lib", ".", "EnvGetDefclassName", "(", "self", ".", "_env", ",", "self", ".", "_cls", ")", ")", ".", "decode", "(", ")" ]
Class name.
[ "Class", "name", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L267-L269
18,228
noxdafox/clipspy
clips/classes.py
Class.module
def module(self): """The module in which the Class is defined. Python equivalent of the CLIPS defglobal-module command. """ modname = ffi.string(lib.EnvDefclassModule(self._env, self._cls)) defmodule = lib.EnvFindDefmodule(self._env, modname) return Module(self._env, defmodule)
python
def module(self): modname = ffi.string(lib.EnvDefclassModule(self._env, self._cls)) defmodule = lib.EnvFindDefmodule(self._env, modname) return Module(self._env, defmodule)
[ "def", "module", "(", "self", ")", ":", "modname", "=", "ffi", ".", "string", "(", "lib", ".", "EnvDefclassModule", "(", "self", ".", "_env", ",", "self", ".", "_cls", ")", ")", "defmodule", "=", "lib", ".", "EnvFindDefmodule", "(", "self", ".", "_en...
The module in which the Class is defined. Python equivalent of the CLIPS defglobal-module command.
[ "The", "module", "in", "which", "the", "Class", "is", "defined", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L272-L281
18,229
noxdafox/clipspy
clips/classes.py
Class.watch_instances
def watch_instances(self, flag): """Whether or not the Class Instances are being watched.""" lib.EnvSetDefclassWatchInstances(self._env, int(flag), self._cls)
python
def watch_instances(self, flag): lib.EnvSetDefclassWatchInstances(self._env, int(flag), self._cls)
[ "def", "watch_instances", "(", "self", ",", "flag", ")", ":", "lib", ".", "EnvSetDefclassWatchInstances", "(", "self", ".", "_env", ",", "int", "(", "flag", ")", ",", "self", ".", "_cls", ")" ]
Whether or not the Class Instances are being watched.
[ "Whether", "or", "not", "the", "Class", "Instances", "are", "being", "watched", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L294-L296
18,230
noxdafox/clipspy
clips/classes.py
Class.watch_slots
def watch_slots(self, flag): """Whether or not the Class Slots are being watched.""" lib.EnvSetDefclassWatchSlots(self._env, int(flag), self._cls)
python
def watch_slots(self, flag): lib.EnvSetDefclassWatchSlots(self._env, int(flag), self._cls)
[ "def", "watch_slots", "(", "self", ",", "flag", ")", ":", "lib", ".", "EnvSetDefclassWatchSlots", "(", "self", ".", "_env", ",", "int", "(", "flag", ")", ",", "self", ".", "_cls", ")" ]
Whether or not the Class Slots are being watched.
[ "Whether", "or", "not", "the", "Class", "Slots", "are", "being", "watched", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L304-L306
18,231
noxdafox/clipspy
clips/classes.py
Class.new_instance
def new_instance(self, name): """Create a new raw instance from this Class. No slot overrides or class default initializations are performed for the instance. This function bypasses message-passing. """ ist = lib.EnvCreateRawInstance(self._env, self._cls, name.encode()) if ist == ffi.NULL: raise CLIPSError(self._env) return Instance(self._env, ist)
python
def new_instance(self, name): ist = lib.EnvCreateRawInstance(self._env, self._cls, name.encode()) if ist == ffi.NULL: raise CLIPSError(self._env) return Instance(self._env, ist)
[ "def", "new_instance", "(", "self", ",", "name", ")", ":", "ist", "=", "lib", ".", "EnvCreateRawInstance", "(", "self", ".", "_env", ",", "self", ".", "_cls", ",", "name", ".", "encode", "(", ")", ")", "if", "ist", "==", "ffi", ".", "NULL", ":", ...
Create a new raw instance from this Class. No slot overrides or class default initializations are performed for the instance. This function bypasses message-passing.
[ "Create", "a", "new", "raw", "instance", "from", "this", "Class", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L308-L321
18,232
noxdafox/clipspy
clips/classes.py
Class.find_message_handler
def find_message_handler(self, handler_name, handler_type='primary'): """Returns the MessageHandler given its name and type for this class.""" ret = lib.EnvFindDefmessageHandler( self._env, self._cls, handler_name.encode(), handler_type.encode()) if ret == 0: raise CLIPSError(self._env) return MessageHandler(self._env, self._cls, ret)
python
def find_message_handler(self, handler_name, handler_type='primary'): ret = lib.EnvFindDefmessageHandler( self._env, self._cls, handler_name.encode(), handler_type.encode()) if ret == 0: raise CLIPSError(self._env) return MessageHandler(self._env, self._cls, ret)
[ "def", "find_message_handler", "(", "self", ",", "handler_name", ",", "handler_type", "=", "'primary'", ")", ":", "ret", "=", "lib", ".", "EnvFindDefmessageHandler", "(", "self", ".", "_env", ",", "self", ".", "_cls", ",", "handler_name", ".", "encode", "(",...
Returns the MessageHandler given its name and type for this class.
[ "Returns", "the", "MessageHandler", "given", "its", "name", "and", "type", "for", "this", "class", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L323-L330
18,233
noxdafox/clipspy
clips/classes.py
Class.subclass
def subclass(self, klass): """True if the Class is a subclass of the given one.""" return bool(lib.EnvSubclassP(self._env, self._cls, klass._cls))
python
def subclass(self, klass): return bool(lib.EnvSubclassP(self._env, self._cls, klass._cls))
[ "def", "subclass", "(", "self", ",", "klass", ")", ":", "return", "bool", "(", "lib", ".", "EnvSubclassP", "(", "self", ".", "_env", ",", "self", ".", "_cls", ",", "klass", ".", "_cls", ")", ")" ]
True if the Class is a subclass of the given one.
[ "True", "if", "the", "Class", "is", "a", "subclass", "of", "the", "given", "one", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L332-L334
18,234
noxdafox/clipspy
clips/classes.py
Class.superclass
def superclass(self, klass): """True if the Class is a superclass of the given one.""" return bool(lib.EnvSuperclassP(self._env, self._cls, klass._cls))
python
def superclass(self, klass): return bool(lib.EnvSuperclassP(self._env, self._cls, klass._cls))
[ "def", "superclass", "(", "self", ",", "klass", ")", ":", "return", "bool", "(", "lib", ".", "EnvSuperclassP", "(", "self", ".", "_env", ",", "self", ".", "_cls", ",", "klass", ".", "_cls", ")", ")" ]
True if the Class is a superclass of the given one.
[ "True", "if", "the", "Class", "is", "a", "superclass", "of", "the", "given", "one", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L336-L338
18,235
noxdafox/clipspy
clips/classes.py
Class.slots
def slots(self, inherited=False): """Iterate over the Slots of the class.""" data = clips.data.DataObject(self._env) lib.EnvClassSlots(self._env, self._cls, data.byref, int(inherited)) return (ClassSlot(self._env, self._cls, n.encode()) for n in data.value)
python
def slots(self, inherited=False): data = clips.data.DataObject(self._env) lib.EnvClassSlots(self._env, self._cls, data.byref, int(inherited)) return (ClassSlot(self._env, self._cls, n.encode()) for n in data.value)
[ "def", "slots", "(", "self", ",", "inherited", "=", "False", ")", ":", "data", "=", "clips", ".", "data", ".", "DataObject", "(", "self", ".", "_env", ")", "lib", ".", "EnvClassSlots", "(", "self", ".", "_env", ",", "self", ".", "_cls", ",", "data"...
Iterate over the Slots of the class.
[ "Iterate", "over", "the", "Slots", "of", "the", "class", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L340-L346
18,236
noxdafox/clipspy
clips/classes.py
Class.instances
def instances(self): """Iterate over the instances of the class.""" ist = lib.EnvGetNextInstanceInClass(self._env, self._cls, ffi.NULL) while ist != ffi.NULL: yield Instance(self._env, ist) ist = lib.EnvGetNextInstanceInClass(self._env, self._cls, ist)
python
def instances(self): ist = lib.EnvGetNextInstanceInClass(self._env, self._cls, ffi.NULL) while ist != ffi.NULL: yield Instance(self._env, ist) ist = lib.EnvGetNextInstanceInClass(self._env, self._cls, ist)
[ "def", "instances", "(", "self", ")", ":", "ist", "=", "lib", ".", "EnvGetNextInstanceInClass", "(", "self", ".", "_env", ",", "self", ".", "_cls", ",", "ffi", ".", "NULL", ")", "while", "ist", "!=", "ffi", ".", "NULL", ":", "yield", "Instance", "(",...
Iterate over the instances of the class.
[ "Iterate", "over", "the", "instances", "of", "the", "class", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L348-L355
18,237
noxdafox/clipspy
clips/classes.py
Class.subclasses
def subclasses(self, inherited=False): """Iterate over the subclasses of the class. This function is the Python equivalent of the CLIPS class-subclasses command. """ data = clips.data.DataObject(self._env) lib.EnvClassSubclasses(self._env, self._cls, data.byref, int(inherited)) for klass in classes(self._env, data.value): yield klass
python
def subclasses(self, inherited=False): data = clips.data.DataObject(self._env) lib.EnvClassSubclasses(self._env, self._cls, data.byref, int(inherited)) for klass in classes(self._env, data.value): yield klass
[ "def", "subclasses", "(", "self", ",", "inherited", "=", "False", ")", ":", "data", "=", "clips", ".", "data", ".", "DataObject", "(", "self", ".", "_env", ")", "lib", ".", "EnvClassSubclasses", "(", "self", ".", "_env", ",", "self", ".", "_cls", ","...
Iterate over the subclasses of the class. This function is the Python equivalent of the CLIPS class-subclasses command.
[ "Iterate", "over", "the", "subclasses", "of", "the", "class", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L357-L369
18,238
noxdafox/clipspy
clips/classes.py
Class.superclasses
def superclasses(self, inherited=False): """Iterate over the superclasses of the class. This function is the Python equivalent of the CLIPS class-superclasses command. """ data = clips.data.DataObject(self._env) lib.EnvClassSuperclasses( self._env, self._cls, data.byref, int(inherited)) for klass in classes(self._env, data.value): yield klass
python
def superclasses(self, inherited=False): data = clips.data.DataObject(self._env) lib.EnvClassSuperclasses( self._env, self._cls, data.byref, int(inherited)) for klass in classes(self._env, data.value): yield klass
[ "def", "superclasses", "(", "self", ",", "inherited", "=", "False", ")", ":", "data", "=", "clips", ".", "data", ".", "DataObject", "(", "self", ".", "_env", ")", "lib", ".", "EnvClassSuperclasses", "(", "self", ".", "_env", ",", "self", ".", "_cls", ...
Iterate over the superclasses of the class. This function is the Python equivalent of the CLIPS class-superclasses command.
[ "Iterate", "over", "the", "superclasses", "of", "the", "class", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L371-L384
18,239
noxdafox/clipspy
clips/classes.py
Class.message_handlers
def message_handlers(self): """Iterate over the message handlers of the class.""" index = lib.EnvGetNextDefmessageHandler(self._env, self._cls, 0) while index != 0: yield MessageHandler(self._env, self._cls, index) index = lib.EnvGetNextDefmessageHandler(self._env, self._cls, index)
python
def message_handlers(self): index = lib.EnvGetNextDefmessageHandler(self._env, self._cls, 0) while index != 0: yield MessageHandler(self._env, self._cls, index) index = lib.EnvGetNextDefmessageHandler(self._env, self._cls, index)
[ "def", "message_handlers", "(", "self", ")", ":", "index", "=", "lib", ".", "EnvGetNextDefmessageHandler", "(", "self", ".", "_env", ",", "self", ".", "_cls", ",", "0", ")", "while", "index", "!=", "0", ":", "yield", "MessageHandler", "(", "self", ".", ...
Iterate over the message handlers of the class.
[ "Iterate", "over", "the", "message", "handlers", "of", "the", "class", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L386-L393
18,240
noxdafox/clipspy
clips/classes.py
Class.undefine
def undefine(self): """Undefine the Class. Python equivalent of the CLIPS undefclass command. The object becomes unusable after this method has been called. """ if lib.EnvUndefclass(self._env, self._cls) != 1: raise CLIPSError(self._env) self._env = None
python
def undefine(self): if lib.EnvUndefclass(self._env, self._cls) != 1: raise CLIPSError(self._env) self._env = None
[ "def", "undefine", "(", "self", ")", ":", "if", "lib", ".", "EnvUndefclass", "(", "self", ".", "_env", ",", "self", ".", "_cls", ")", "!=", "1", ":", "raise", "CLIPSError", "(", "self", ".", "_env", ")", "self", ".", "_env", "=", "None" ]
Undefine the Class. Python equivalent of the CLIPS undefclass command. The object becomes unusable after this method has been called.
[ "Undefine", "the", "Class", "." ]
b22d71a6da821c1715d8fa00d7d75cabc09ed364
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L395-L406
18,241
adamrehn/ue4cli
ue4cli/Utility.py
Utility.findArgs
def findArgs(args, prefixes): """ Extracts the list of arguments that start with any of the specified prefix values """ return list([ arg for arg in args if len([p for p in prefixes if arg.lower().startswith(p.lower())]) > 0 ])
python
def findArgs(args, prefixes): return list([ arg for arg in args if len([p for p in prefixes if arg.lower().startswith(p.lower())]) > 0 ])
[ "def", "findArgs", "(", "args", ",", "prefixes", ")", ":", "return", "list", "(", "[", "arg", "for", "arg", "in", "args", "if", "len", "(", "[", "p", "for", "p", "in", "prefixes", "if", "arg", ".", "lower", "(", ")", ".", "startswith", "(", "p", ...
Extracts the list of arguments that start with any of the specified prefix values
[ "Extracts", "the", "list", "of", "arguments", "that", "start", "with", "any", "of", "the", "specified", "prefix", "values" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L86-L93
18,242
adamrehn/ue4cli
ue4cli/Utility.py
Utility.stripArgs
def stripArgs(args, blacklist): """ Removes any arguments in the supplied list that are contained in the specified blacklist """ blacklist = [b.lower() for b in blacklist] return list([arg for arg in args if arg.lower() not in blacklist])
python
def stripArgs(args, blacklist): blacklist = [b.lower() for b in blacklist] return list([arg for arg in args if arg.lower() not in blacklist])
[ "def", "stripArgs", "(", "args", ",", "blacklist", ")", ":", "blacklist", "=", "[", "b", ".", "lower", "(", ")", "for", "b", "in", "blacklist", "]", "return", "list", "(", "[", "arg", "for", "arg", "in", "args", "if", "arg", ".", "lower", "(", ")...
Removes any arguments in the supplied list that are contained in the specified blacklist
[ "Removes", "any", "arguments", "in", "the", "supplied", "list", "that", "are", "contained", "in", "the", "specified", "blacklist" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L103-L108
18,243
adamrehn/ue4cli
ue4cli/Utility.py
Utility.capture
def capture(command, input=None, cwd=None, shell=False, raiseOnError=False): """ Executes a child process and captures its output """ # Attempt to execute the child process proc = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd, shell=shell, universal_newlines=True) (stdout, stderr) = proc.communicate(input) # If the child process failed and we were asked to raise an exception, do so if raiseOnError == True and proc.returncode != 0: raise Exception( 'child process ' + str(command) + ' failed with exit code ' + str(proc.returncode) + '\nstdout: "' + stdout + '"' + '\nstderr: "' + stderr + '"' ) return CommandOutput(proc.returncode, stdout, stderr)
python
def capture(command, input=None, cwd=None, shell=False, raiseOnError=False): # Attempt to execute the child process proc = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd, shell=shell, universal_newlines=True) (stdout, stderr) = proc.communicate(input) # If the child process failed and we were asked to raise an exception, do so if raiseOnError == True and proc.returncode != 0: raise Exception( 'child process ' + str(command) + ' failed with exit code ' + str(proc.returncode) + '\nstdout: "' + stdout + '"' + '\nstderr: "' + stderr + '"' ) return CommandOutput(proc.returncode, stdout, stderr)
[ "def", "capture", "(", "command", ",", "input", "=", "None", ",", "cwd", "=", "None", ",", "shell", "=", "False", ",", "raiseOnError", "=", "False", ")", ":", "# Attempt to execute the child process", "proc", "=", "subprocess", ".", "Popen", "(", "command", ...
Executes a child process and captures its output
[ "Executes", "a", "child", "process", "and", "captures", "its", "output" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L111-L129
18,244
adamrehn/ue4cli
ue4cli/Utility.py
Utility.run
def run(command, cwd=None, shell=False, raiseOnError=False): """ Executes a child process and waits for it to complete """ returncode = subprocess.call(command, cwd=cwd, shell=shell) if raiseOnError == True and returncode != 0: raise Exception('child process ' + str(command) + ' failed with exit code ' + str(returncode)) return returncode
python
def run(command, cwd=None, shell=False, raiseOnError=False): returncode = subprocess.call(command, cwd=cwd, shell=shell) if raiseOnError == True and returncode != 0: raise Exception('child process ' + str(command) + ' failed with exit code ' + str(returncode)) return returncode
[ "def", "run", "(", "command", ",", "cwd", "=", "None", ",", "shell", "=", "False", ",", "raiseOnError", "=", "False", ")", ":", "returncode", "=", "subprocess", ".", "call", "(", "command", ",", "cwd", "=", "cwd", ",", "shell", "=", "shell", ")", "...
Executes a child process and waits for it to complete
[ "Executes", "a", "child", "process", "and", "waits", "for", "it", "to", "complete" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L132-L139
18,245
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.setEngineRootOverride
def setEngineRootOverride(self, rootDir): """ Sets a user-specified directory as the root engine directory, overriding any auto-detection """ # Set the new root directory ConfigurationManager.setConfigKey('rootDirOverride', os.path.abspath(rootDir)) # Check that the specified directory is valid and warn the user if it is not try: self.getEngineVersion() except: print('Warning: the specified directory does not appear to contain a valid version of the Unreal Engine.')
python
def setEngineRootOverride(self, rootDir): # Set the new root directory ConfigurationManager.setConfigKey('rootDirOverride', os.path.abspath(rootDir)) # Check that the specified directory is valid and warn the user if it is not try: self.getEngineVersion() except: print('Warning: the specified directory does not appear to contain a valid version of the Unreal Engine.')
[ "def", "setEngineRootOverride", "(", "self", ",", "rootDir", ")", ":", "# Set the new root directory", "ConfigurationManager", ".", "setConfigKey", "(", "'rootDirOverride'", ",", "os", ".", "path", ".", "abspath", "(", "rootDir", ")", ")", "# Check that the specified ...
Sets a user-specified directory as the root engine directory, overriding any auto-detection
[ "Sets", "a", "user", "-", "specified", "directory", "as", "the", "root", "engine", "directory", "overriding", "any", "auto", "-", "detection" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L33-L45
18,246
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getEngineRoot
def getEngineRoot(self): """ Returns the root directory location of the latest installed version of UE4 """ if not hasattr(self, '_engineRoot'): self._engineRoot = self._getEngineRoot() return self._engineRoot
python
def getEngineRoot(self): if not hasattr(self, '_engineRoot'): self._engineRoot = self._getEngineRoot() return self._engineRoot
[ "def", "getEngineRoot", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_engineRoot'", ")", ":", "self", ".", "_engineRoot", "=", "self", ".", "_getEngineRoot", "(", ")", "return", "self", ".", "_engineRoot" ]
Returns the root directory location of the latest installed version of UE4
[ "Returns", "the", "root", "directory", "location", "of", "the", "latest", "installed", "version", "of", "UE4" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L53-L59
18,247
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getEngineVersion
def getEngineVersion(self, outputFormat = 'full'): """ Returns the version number of the latest installed version of UE4 """ version = self._getEngineVersionDetails() formats = { 'major': version['MajorVersion'], 'minor': version['MinorVersion'], 'patch': version['PatchVersion'], 'full': '{}.{}.{}'.format(version['MajorVersion'], version['MinorVersion'], version['PatchVersion']), 'short': '{}.{}'.format(version['MajorVersion'], version['MinorVersion']) } # Verify that the requested output format is valid if outputFormat not in formats: raise Exception('unreconised version output format "{}"'.format(outputFormat)) return formats[outputFormat]
python
def getEngineVersion(self, outputFormat = 'full'): version = self._getEngineVersionDetails() formats = { 'major': version['MajorVersion'], 'minor': version['MinorVersion'], 'patch': version['PatchVersion'], 'full': '{}.{}.{}'.format(version['MajorVersion'], version['MinorVersion'], version['PatchVersion']), 'short': '{}.{}'.format(version['MajorVersion'], version['MinorVersion']) } # Verify that the requested output format is valid if outputFormat not in formats: raise Exception('unreconised version output format "{}"'.format(outputFormat)) return formats[outputFormat]
[ "def", "getEngineVersion", "(", "self", ",", "outputFormat", "=", "'full'", ")", ":", "version", "=", "self", ".", "_getEngineVersionDetails", "(", ")", "formats", "=", "{", "'major'", ":", "version", "[", "'MajorVersion'", "]", ",", "'minor'", ":", "version...
Returns the version number of the latest installed version of UE4
[ "Returns", "the", "version", "number", "of", "the", "latest", "installed", "version", "of", "UE4" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L61-L78
18,248
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getEngineChangelist
def getEngineChangelist(self): """ Returns the compatible Perforce changelist identifier for the latest installed version of UE4 """ # Newer versions of the engine use the key "CompatibleChangelist", older ones use "Changelist" version = self._getEngineVersionDetails() if 'CompatibleChangelist' in version: return int(version['CompatibleChangelist']) else: return int(version['Changelist'])
python
def getEngineChangelist(self): # Newer versions of the engine use the key "CompatibleChangelist", older ones use "Changelist" version = self._getEngineVersionDetails() if 'CompatibleChangelist' in version: return int(version['CompatibleChangelist']) else: return int(version['Changelist'])
[ "def", "getEngineChangelist", "(", "self", ")", ":", "# Newer versions of the engine use the key \"CompatibleChangelist\", older ones use \"Changelist\"", "version", "=", "self", ".", "_getEngineVersionDetails", "(", ")", "if", "'CompatibleChangelist'", "in", "version", ":", "r...
Returns the compatible Perforce changelist identifier for the latest installed version of UE4
[ "Returns", "the", "compatible", "Perforce", "changelist", "identifier", "for", "the", "latest", "installed", "version", "of", "UE4" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L80-L90
18,249
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.isInstalledBuild
def isInstalledBuild(self): """ Determines if the Engine is an Installed Build """ sentinelFile = os.path.join(self.getEngineRoot(), 'Engine', 'Build', 'InstalledBuild.txt') return os.path.exists(sentinelFile)
python
def isInstalledBuild(self): sentinelFile = os.path.join(self.getEngineRoot(), 'Engine', 'Build', 'InstalledBuild.txt') return os.path.exists(sentinelFile)
[ "def", "isInstalledBuild", "(", "self", ")", ":", "sentinelFile", "=", "os", ".", "path", ".", "join", "(", "self", ".", "getEngineRoot", "(", ")", ",", "'Engine'", ",", "'Build'", ",", "'InstalledBuild.txt'", ")", "return", "os", ".", "path", ".", "exis...
Determines if the Engine is an Installed Build
[ "Determines", "if", "the", "Engine", "is", "an", "Installed", "Build" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L92-L97
18,250
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getEditorBinary
def getEditorBinary(self, cmdVersion=False): """ Determines the location of the UE4Editor binary """ return os.path.join(self.getEngineRoot(), 'Engine', 'Binaries', self.getPlatformIdentifier(), 'UE4Editor' + self._editorPathSuffix(cmdVersion))
python
def getEditorBinary(self, cmdVersion=False): return os.path.join(self.getEngineRoot(), 'Engine', 'Binaries', self.getPlatformIdentifier(), 'UE4Editor' + self._editorPathSuffix(cmdVersion))
[ "def", "getEditorBinary", "(", "self", ",", "cmdVersion", "=", "False", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "getEngineRoot", "(", ")", ",", "'Engine'", ",", "'Binaries'", ",", "self", ".", "getPlatformIdentifier", "(", "...
Determines the location of the UE4Editor binary
[ "Determines", "the", "location", "of", "the", "UE4Editor", "binary" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L99-L103
18,251
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getProjectDescriptor
def getProjectDescriptor(self, dir): """ Detects the .uproject descriptor file for the Unreal project in the specified directory """ for project in glob.glob(os.path.join(dir, '*.uproject')): return os.path.realpath(project) # No project detected raise UnrealManagerException('could not detect an Unreal project in the current directory')
python
def getProjectDescriptor(self, dir): for project in glob.glob(os.path.join(dir, '*.uproject')): return os.path.realpath(project) # No project detected raise UnrealManagerException('could not detect an Unreal project in the current directory')
[ "def", "getProjectDescriptor", "(", "self", ",", "dir", ")", ":", "for", "project", "in", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "dir", ",", "'*.uproject'", ")", ")", ":", "return", "os", ".", "path", ".", "realpath", "(", "...
Detects the .uproject descriptor file for the Unreal project in the specified directory
[ "Detects", "the", ".", "uproject", "descriptor", "file", "for", "the", "Unreal", "project", "in", "the", "specified", "directory" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L123-L131
18,252
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getPluginDescriptor
def getPluginDescriptor(self, dir): """ Detects the .uplugin descriptor file for the Unreal plugin in the specified directory """ for plugin in glob.glob(os.path.join(dir, '*.uplugin')): return os.path.realpath(plugin) # No plugin detected raise UnrealManagerException('could not detect an Unreal plugin in the current directory')
python
def getPluginDescriptor(self, dir): for plugin in glob.glob(os.path.join(dir, '*.uplugin')): return os.path.realpath(plugin) # No plugin detected raise UnrealManagerException('could not detect an Unreal plugin in the current directory')
[ "def", "getPluginDescriptor", "(", "self", ",", "dir", ")", ":", "for", "plugin", "in", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "dir", ",", "'*.uplugin'", ")", ")", ":", "return", "os", ".", "path", ".", "realpath", "(", "plu...
Detects the .uplugin descriptor file for the Unreal plugin in the specified directory
[ "Detects", "the", ".", "uplugin", "descriptor", "file", "for", "the", "Unreal", "plugin", "in", "the", "specified", "directory" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L133-L141
18,253
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getDescriptor
def getDescriptor(self, dir): """ Detects the descriptor file for either an Unreal project or an Unreal plugin in the specified directory """ try: return self.getProjectDescriptor(dir) except: try: return self.getPluginDescriptor(dir) except: raise UnrealManagerException('could not detect an Unreal project or plugin in the directory "{}"'.format(dir))
python
def getDescriptor(self, dir): try: return self.getProjectDescriptor(dir) except: try: return self.getPluginDescriptor(dir) except: raise UnrealManagerException('could not detect an Unreal project or plugin in the directory "{}"'.format(dir))
[ "def", "getDescriptor", "(", "self", ",", "dir", ")", ":", "try", ":", "return", "self", ".", "getProjectDescriptor", "(", "dir", ")", "except", ":", "try", ":", "return", "self", ".", "getPluginDescriptor", "(", "dir", ")", "except", ":", "raise", "Unre...
Detects the descriptor file for either an Unreal project or an Unreal plugin in the specified directory
[ "Detects", "the", "descriptor", "file", "for", "either", "an", "Unreal", "project", "or", "an", "Unreal", "plugin", "in", "the", "specified", "directory" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L143-L153
18,254
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.listThirdPartyLibs
def listThirdPartyLibs(self, configuration = 'Development'): """ Lists the supported Unreal-bundled third-party libraries """ interrogator = self._getUE4BuildInterrogator() return interrogator.list(self.getPlatformIdentifier(), configuration, self._getLibraryOverrides())
python
def listThirdPartyLibs(self, configuration = 'Development'): interrogator = self._getUE4BuildInterrogator() return interrogator.list(self.getPlatformIdentifier(), configuration, self._getLibraryOverrides())
[ "def", "listThirdPartyLibs", "(", "self", ",", "configuration", "=", "'Development'", ")", ":", "interrogator", "=", "self", ".", "_getUE4BuildInterrogator", "(", ")", "return", "interrogator", ".", "list", "(", "self", ".", "getPlatformIdentifier", "(", ")", ",...
Lists the supported Unreal-bundled third-party libraries
[ "Lists", "the", "supported", "Unreal", "-", "bundled", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L173-L178
18,255
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getThirdpartyLibs
def getThirdpartyLibs(self, libs, configuration = 'Development', includePlatformDefaults = True): """ Retrieves the ThirdPartyLibraryDetails instance for Unreal-bundled versions of the specified third-party libraries """ if includePlatformDefaults == True: libs = self._defaultThirdpartyLibs() + libs interrogator = self._getUE4BuildInterrogator() return interrogator.interrogate(self.getPlatformIdentifier(), configuration, libs, self._getLibraryOverrides())
python
def getThirdpartyLibs(self, libs, configuration = 'Development', includePlatformDefaults = True): if includePlatformDefaults == True: libs = self._defaultThirdpartyLibs() + libs interrogator = self._getUE4BuildInterrogator() return interrogator.interrogate(self.getPlatformIdentifier(), configuration, libs, self._getLibraryOverrides())
[ "def", "getThirdpartyLibs", "(", "self", ",", "libs", ",", "configuration", "=", "'Development'", ",", "includePlatformDefaults", "=", "True", ")", ":", "if", "includePlatformDefaults", "==", "True", ":", "libs", "=", "self", ".", "_defaultThirdpartyLibs", "(", ...
Retrieves the ThirdPartyLibraryDetails instance for Unreal-bundled versions of the specified third-party libraries
[ "Retrieves", "the", "ThirdPartyLibraryDetails", "instance", "for", "Unreal", "-", "bundled", "versions", "of", "the", "specified", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L180-L187
18,256
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getThirdPartyLibCompilerFlags
def getThirdPartyLibCompilerFlags(self, libs): """ Retrieves the compiler flags for building against the Unreal-bundled versions of the specified third-party libraries """ fmt = PrintingFormat.singleLine() if libs[0] == '--multiline': fmt = PrintingFormat.multiLine() libs = libs[1:] platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getCompilerFlags(self.getEngineRoot(), fmt)
python
def getThirdPartyLibCompilerFlags(self, libs): fmt = PrintingFormat.singleLine() if libs[0] == '--multiline': fmt = PrintingFormat.multiLine() libs = libs[1:] platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getCompilerFlags(self.getEngineRoot(), fmt)
[ "def", "getThirdPartyLibCompilerFlags", "(", "self", ",", "libs", ")", ":", "fmt", "=", "PrintingFormat", ".", "singleLine", "(", ")", "if", "libs", "[", "0", "]", "==", "'--multiline'", ":", "fmt", "=", "PrintingFormat", ".", "multiLine", "(", ")", "libs"...
Retrieves the compiler flags for building against the Unreal-bundled versions of the specified third-party libraries
[ "Retrieves", "the", "compiler", "flags", "for", "building", "against", "the", "Unreal", "-", "bundled", "versions", "of", "the", "specified", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L189-L204
18,257
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getThirdPartyLibLinkerFlags
def getThirdPartyLibLinkerFlags(self, libs): """ Retrieves the linker flags for building against the Unreal-bundled versions of the specified third-party libraries """ fmt = PrintingFormat.singleLine() if libs[0] == '--multiline': fmt = PrintingFormat.multiLine() libs = libs[1:] includeLibs = True if (libs[0] == '--flagsonly'): includeLibs = False libs = libs[1:] platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getLinkerFlags(self.getEngineRoot(), fmt, includeLibs)
python
def getThirdPartyLibLinkerFlags(self, libs): fmt = PrintingFormat.singleLine() if libs[0] == '--multiline': fmt = PrintingFormat.multiLine() libs = libs[1:] includeLibs = True if (libs[0] == '--flagsonly'): includeLibs = False libs = libs[1:] platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getLinkerFlags(self.getEngineRoot(), fmt, includeLibs)
[ "def", "getThirdPartyLibLinkerFlags", "(", "self", ",", "libs", ")", ":", "fmt", "=", "PrintingFormat", ".", "singleLine", "(", ")", "if", "libs", "[", "0", "]", "==", "'--multiline'", ":", "fmt", "=", "PrintingFormat", ".", "multiLine", "(", ")", "libs", ...
Retrieves the linker flags for building against the Unreal-bundled versions of the specified third-party libraries
[ "Retrieves", "the", "linker", "flags", "for", "building", "against", "the", "Unreal", "-", "bundled", "versions", "of", "the", "specified", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L206-L226
18,258
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getThirdPartyLibCmakeFlags
def getThirdPartyLibCmakeFlags(self, libs): """ Retrieves the CMake invocation flags for building against the Unreal-bundled versions of the specified third-party libraries """ fmt = PrintingFormat.singleLine() if libs[0] == '--multiline': fmt = PrintingFormat.multiLine() libs = libs[1:] platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) CMakeCustomFlags.processLibraryDetails(details) return details.getCMakeFlags(self.getEngineRoot(), fmt)
python
def getThirdPartyLibCmakeFlags(self, libs): fmt = PrintingFormat.singleLine() if libs[0] == '--multiline': fmt = PrintingFormat.multiLine() libs = libs[1:] platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) CMakeCustomFlags.processLibraryDetails(details) return details.getCMakeFlags(self.getEngineRoot(), fmt)
[ "def", "getThirdPartyLibCmakeFlags", "(", "self", ",", "libs", ")", ":", "fmt", "=", "PrintingFormat", ".", "singleLine", "(", ")", "if", "libs", "[", "0", "]", "==", "'--multiline'", ":", "fmt", "=", "PrintingFormat", ".", "multiLine", "(", ")", "libs", ...
Retrieves the CMake invocation flags for building against the Unreal-bundled versions of the specified third-party libraries
[ "Retrieves", "the", "CMake", "invocation", "flags", "for", "building", "against", "the", "Unreal", "-", "bundled", "versions", "of", "the", "specified", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L228-L244
18,259
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getThirdPartyLibIncludeDirs
def getThirdPartyLibIncludeDirs(self, libs): """ Retrieves the list of include directories for building against the Unreal-bundled versions of the specified third-party libraries """ platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getIncludeDirectories(self.getEngineRoot(), delimiter='\n')
python
def getThirdPartyLibIncludeDirs(self, libs): platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getIncludeDirectories(self.getEngineRoot(), delimiter='\n')
[ "def", "getThirdPartyLibIncludeDirs", "(", "self", ",", "libs", ")", ":", "platformDefaults", "=", "True", "if", "libs", "[", "0", "]", "==", "'--nodefaults'", ":", "platformDefaults", "=", "False", "libs", "=", "libs", "[", "1", ":", "]", "details", "=", ...
Retrieves the list of include directories for building against the Unreal-bundled versions of the specified third-party libraries
[ "Retrieves", "the", "list", "of", "include", "directories", "for", "building", "against", "the", "Unreal", "-", "bundled", "versions", "of", "the", "specified", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L246-L256
18,260
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getThirdPartyLibFiles
def getThirdPartyLibFiles(self, libs): """ Retrieves the list of library files for building against the Unreal-bundled versions of the specified third-party libraries """ platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getLibraryFiles(self.getEngineRoot(), delimiter='\n')
python
def getThirdPartyLibFiles(self, libs): platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getLibraryFiles(self.getEngineRoot(), delimiter='\n')
[ "def", "getThirdPartyLibFiles", "(", "self", ",", "libs", ")", ":", "platformDefaults", "=", "True", "if", "libs", "[", "0", "]", "==", "'--nodefaults'", ":", "platformDefaults", "=", "False", "libs", "=", "libs", "[", "1", ":", "]", "details", "=", "sel...
Retrieves the list of library files for building against the Unreal-bundled versions of the specified third-party libraries
[ "Retrieves", "the", "list", "of", "library", "files", "for", "building", "against", "the", "Unreal", "-", "bundled", "versions", "of", "the", "specified", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L258-L268
18,261
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.getThirdPartyLibDefinitions
def getThirdPartyLibDefinitions(self, libs): """ Retrieves the list of preprocessor definitions for building against the Unreal-bundled versions of the specified third-party libraries """ platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getPreprocessorDefinitions(self.getEngineRoot(), delimiter='\n')
python
def getThirdPartyLibDefinitions(self, libs): platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getPreprocessorDefinitions(self.getEngineRoot(), delimiter='\n')
[ "def", "getThirdPartyLibDefinitions", "(", "self", ",", "libs", ")", ":", "platformDefaults", "=", "True", "if", "libs", "[", "0", "]", "==", "'--nodefaults'", ":", "platformDefaults", "=", "False", "libs", "=", "libs", "[", "1", ":", "]", "details", "=", ...
Retrieves the list of preprocessor definitions for building against the Unreal-bundled versions of the specified third-party libraries
[ "Retrieves", "the", "list", "of", "preprocessor", "definitions", "for", "building", "against", "the", "Unreal", "-", "bundled", "versions", "of", "the", "specified", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L270-L280
18,262
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.generateProjectFiles
def generateProjectFiles(self, dir=os.getcwd(), args=[]): """ Generates IDE project files for the Unreal project in the specified directory """ # If the project is a pure Blueprint project, then we cannot generate project files if os.path.exists(os.path.join(dir, 'Source')) == False: Utility.printStderr('Pure Blueprint project, nothing to generate project files for.') return # Generate the project files genScript = self.getGenerateScript() projectFile = self.getProjectDescriptor(dir) Utility.run([genScript, '-project=' + projectFile, '-game', '-engine'] + args, cwd=os.path.dirname(genScript), raiseOnError=True)
python
def generateProjectFiles(self, dir=os.getcwd(), args=[]): # If the project is a pure Blueprint project, then we cannot generate project files if os.path.exists(os.path.join(dir, 'Source')) == False: Utility.printStderr('Pure Blueprint project, nothing to generate project files for.') return # Generate the project files genScript = self.getGenerateScript() projectFile = self.getProjectDescriptor(dir) Utility.run([genScript, '-project=' + projectFile, '-game', '-engine'] + args, cwd=os.path.dirname(genScript), raiseOnError=True)
[ "def", "generateProjectFiles", "(", "self", ",", "dir", "=", "os", ".", "getcwd", "(", ")", ",", "args", "=", "[", "]", ")", ":", "# If the project is a pure Blueprint project, then we cannot generate project files", "if", "os", ".", "path", ".", "exists", "(", ...
Generates IDE project files for the Unreal project in the specified directory
[ "Generates", "IDE", "project", "files", "for", "the", "Unreal", "project", "in", "the", "specified", "directory" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L282-L295
18,263
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.cleanDescriptor
def cleanDescriptor(self, dir=os.getcwd()): """ Cleans the build artifacts for the Unreal project or plugin in the specified directory """ # Verify that an Unreal project or plugin exists in the specified directory descriptor = self.getDescriptor(dir) # Because performing a clean will also delete the engine build itself when using # a source build, we simply delete the `Binaries` and `Intermediate` directories shutil.rmtree(os.path.join(dir, 'Binaries'), ignore_errors=True) shutil.rmtree(os.path.join(dir, 'Intermediate'), ignore_errors=True) # If we are cleaning a project, also clean any plugins if self.isProject(descriptor): projectPlugins = glob.glob(os.path.join(dir, 'Plugins', '*')) for pluginDir in projectPlugins: self.cleanDescriptor(pluginDir)
python
def cleanDescriptor(self, dir=os.getcwd()): # Verify that an Unreal project or plugin exists in the specified directory descriptor = self.getDescriptor(dir) # Because performing a clean will also delete the engine build itself when using # a source build, we simply delete the `Binaries` and `Intermediate` directories shutil.rmtree(os.path.join(dir, 'Binaries'), ignore_errors=True) shutil.rmtree(os.path.join(dir, 'Intermediate'), ignore_errors=True) # If we are cleaning a project, also clean any plugins if self.isProject(descriptor): projectPlugins = glob.glob(os.path.join(dir, 'Plugins', '*')) for pluginDir in projectPlugins: self.cleanDescriptor(pluginDir)
[ "def", "cleanDescriptor", "(", "self", ",", "dir", "=", "os", ".", "getcwd", "(", ")", ")", ":", "# Verify that an Unreal project or plugin exists in the specified directory", "descriptor", "=", "self", ".", "getDescriptor", "(", "dir", ")", "# Because performing a clea...
Cleans the build artifacts for the Unreal project or plugin in the specified directory
[ "Cleans", "the", "build", "artifacts", "for", "the", "Unreal", "project", "or", "plugin", "in", "the", "specified", "directory" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L297-L314
18,264
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.buildDescriptor
def buildDescriptor(self, dir=os.getcwd(), configuration='Development', args=[], suppressOutput=False): """ Builds the editor modules for the Unreal project or plugin in the specified directory, using the specified build configuration """ # Verify that an Unreal project or plugin exists in the specified directory descriptor = self.getDescriptor(dir) descriptorType = 'project' if self.isProject(descriptor) else 'plugin' # If the project or plugin is Blueprint-only, there is no C++ code to build if os.path.exists(os.path.join(dir, 'Source')) == False: Utility.printStderr('Pure Blueprint {}, nothing to build.'.format(descriptorType)) return # Verify that the specified build configuration is valid if configuration not in self.validBuildConfigurations(): raise UnrealManagerException('invalid build configuration "' + configuration + '"') # Generate the arguments to pass to UBT target = self.getDescriptorName(descriptor) + 'Editor' if self.isProject(descriptor) else 'UE4Editor' baseArgs = ['-{}='.format(descriptorType) + descriptor] # Perform the build self._runUnrealBuildTool(target, self.getPlatformIdentifier(), configuration, baseArgs + args, capture=suppressOutput)
python
def buildDescriptor(self, dir=os.getcwd(), configuration='Development', args=[], suppressOutput=False): # Verify that an Unreal project or plugin exists in the specified directory descriptor = self.getDescriptor(dir) descriptorType = 'project' if self.isProject(descriptor) else 'plugin' # If the project or plugin is Blueprint-only, there is no C++ code to build if os.path.exists(os.path.join(dir, 'Source')) == False: Utility.printStderr('Pure Blueprint {}, nothing to build.'.format(descriptorType)) return # Verify that the specified build configuration is valid if configuration not in self.validBuildConfigurations(): raise UnrealManagerException('invalid build configuration "' + configuration + '"') # Generate the arguments to pass to UBT target = self.getDescriptorName(descriptor) + 'Editor' if self.isProject(descriptor) else 'UE4Editor' baseArgs = ['-{}='.format(descriptorType) + descriptor] # Perform the build self._runUnrealBuildTool(target, self.getPlatformIdentifier(), configuration, baseArgs + args, capture=suppressOutput)
[ "def", "buildDescriptor", "(", "self", ",", "dir", "=", "os", ".", "getcwd", "(", ")", ",", "configuration", "=", "'Development'", ",", "args", "=", "[", "]", ",", "suppressOutput", "=", "False", ")", ":", "# Verify that an Unreal project or plugin exists in the...
Builds the editor modules for the Unreal project or plugin in the specified directory, using the specified build configuration
[ "Builds", "the", "editor", "modules", "for", "the", "Unreal", "project", "or", "plugin", "in", "the", "specified", "directory", "using", "the", "specified", "build", "configuration" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L316-L339
18,265
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.runUAT
def runUAT(self, args): """ Runs the Unreal Automation Tool with the supplied arguments """ Utility.run([self.getRunUATScript()] + args, cwd=self.getEngineRoot(), raiseOnError=True)
python
def runUAT(self, args): Utility.run([self.getRunUATScript()] + args, cwd=self.getEngineRoot(), raiseOnError=True)
[ "def", "runUAT", "(", "self", ",", "args", ")", ":", "Utility", ".", "run", "(", "[", "self", ".", "getRunUATScript", "(", ")", "]", "+", "args", ",", "cwd", "=", "self", ".", "getEngineRoot", "(", ")", ",", "raiseOnError", "=", "True", ")" ]
Runs the Unreal Automation Tool with the supplied arguments
[ "Runs", "the", "Unreal", "Automation", "Tool", "with", "the", "supplied", "arguments" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L349-L353
18,266
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.packageProject
def packageProject(self, dir=os.getcwd(), configuration='Shipping', extraArgs=[]): """ Packages a build of the Unreal project in the specified directory, using common packaging options """ # Verify that the specified build configuration is valid if configuration not in self.validBuildConfigurations(): raise UnrealManagerException('invalid build configuration "' + configuration + '"') # Strip out the `-NoCompileEditor` flag if the user has specified it, since the Development version # of the Editor modules for the project are needed in order to run the commandlet that cooks content extraArgs = Utility.stripArgs(extraArgs, ['-nocompileeditor']) # Prevent the user from specifying multiple `-platform=` or `-targetplatform=` arguments, # and use the current host platform if no platform argument was explicitly specified platformArgs = Utility.findArgs(extraArgs, ['-platform=', '-targetplatform=']) platform = Utility.getArgValue(platformArgs[0]) if len(platformArgs) > 0 else self.getPlatformIdentifier() extraArgs = Utility.stripArgs(extraArgs, platformArgs) + ['-platform={}'.format(platform)] # If we are packaging a Shipping build, do not include debug symbols if configuration == 'Shipping': extraArgs.append('-nodebuginfo') # Do not create a .pak file when packaging for HTML5 pakArg = '-package' if platform.upper() == 'HTML5' else '-pak' # Invoke UAT to package the build distDir = os.path.join(os.path.abspath(dir), 'dist') self.runUAT([ 'BuildCookRun', '-utf8output', '-clientconfig=' + configuration, '-serverconfig=' + configuration, '-project=' + self.getProjectDescriptor(dir), '-noP4', '-cook', '-allmaps', '-build', '-stage', '-prereqs', pakArg, '-archive', '-archivedirectory=' + distDir ] + extraArgs)
python
def packageProject(self, dir=os.getcwd(), configuration='Shipping', extraArgs=[]): # Verify that the specified build configuration is valid if configuration not in self.validBuildConfigurations(): raise UnrealManagerException('invalid build configuration "' + configuration + '"') # Strip out the `-NoCompileEditor` flag if the user has specified it, since the Development version # of the Editor modules for the project are needed in order to run the commandlet that cooks content extraArgs = Utility.stripArgs(extraArgs, ['-nocompileeditor']) # Prevent the user from specifying multiple `-platform=` or `-targetplatform=` arguments, # and use the current host platform if no platform argument was explicitly specified platformArgs = Utility.findArgs(extraArgs, ['-platform=', '-targetplatform=']) platform = Utility.getArgValue(platformArgs[0]) if len(platformArgs) > 0 else self.getPlatformIdentifier() extraArgs = Utility.stripArgs(extraArgs, platformArgs) + ['-platform={}'.format(platform)] # If we are packaging a Shipping build, do not include debug symbols if configuration == 'Shipping': extraArgs.append('-nodebuginfo') # Do not create a .pak file when packaging for HTML5 pakArg = '-package' if platform.upper() == 'HTML5' else '-pak' # Invoke UAT to package the build distDir = os.path.join(os.path.abspath(dir), 'dist') self.runUAT([ 'BuildCookRun', '-utf8output', '-clientconfig=' + configuration, '-serverconfig=' + configuration, '-project=' + self.getProjectDescriptor(dir), '-noP4', '-cook', '-allmaps', '-build', '-stage', '-prereqs', pakArg, '-archive', '-archivedirectory=' + distDir ] + extraArgs)
[ "def", "packageProject", "(", "self", ",", "dir", "=", "os", ".", "getcwd", "(", ")", ",", "configuration", "=", "'Shipping'", ",", "extraArgs", "=", "[", "]", ")", ":", "# Verify that the specified build configuration is valid", "if", "configuration", "not", "i...
Packages a build of the Unreal project in the specified directory, using common packaging options
[ "Packages", "a", "build", "of", "the", "Unreal", "project", "in", "the", "specified", "directory", "using", "common", "packaging", "options" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L355-L398
18,267
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.packagePlugin
def packagePlugin(self, dir=os.getcwd(), extraArgs=[]): """ Packages a build of the Unreal plugin in the specified directory, suitable for use as a prebuilt Engine module """ # Invoke UAT to package the build distDir = os.path.join(os.path.abspath(dir), 'dist') self.runUAT([ 'BuildPlugin', '-Plugin=' + self.getPluginDescriptor(dir), '-Package=' + distDir ] + extraArgs)
python
def packagePlugin(self, dir=os.getcwd(), extraArgs=[]): # Invoke UAT to package the build distDir = os.path.join(os.path.abspath(dir), 'dist') self.runUAT([ 'BuildPlugin', '-Plugin=' + self.getPluginDescriptor(dir), '-Package=' + distDir ] + extraArgs)
[ "def", "packagePlugin", "(", "self", ",", "dir", "=", "os", ".", "getcwd", "(", ")", ",", "extraArgs", "=", "[", "]", ")", ":", "# Invoke UAT to package the build", "distDir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "abspath",...
Packages a build of the Unreal plugin in the specified directory, suitable for use as a prebuilt Engine module
[ "Packages", "a", "build", "of", "the", "Unreal", "plugin", "in", "the", "specified", "directory", "suitable", "for", "use", "as", "a", "prebuilt", "Engine", "module" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L400-L411
18,268
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.packageDescriptor
def packageDescriptor(self, dir=os.getcwd(), args=[]): """ Packages a build of the Unreal project or plugin in the specified directory """ # Verify that an Unreal project or plugin exists in the specified directory descriptor = self.getDescriptor(dir) # Perform the packaging step if self.isProject(descriptor): self.packageProject(dir, args[0] if len(args) > 0 else 'Shipping', args[1:]) else: self.packagePlugin(dir, args)
python
def packageDescriptor(self, dir=os.getcwd(), args=[]): # Verify that an Unreal project or plugin exists in the specified directory descriptor = self.getDescriptor(dir) # Perform the packaging step if self.isProject(descriptor): self.packageProject(dir, args[0] if len(args) > 0 else 'Shipping', args[1:]) else: self.packagePlugin(dir, args)
[ "def", "packageDescriptor", "(", "self", ",", "dir", "=", "os", ".", "getcwd", "(", ")", ",", "args", "=", "[", "]", ")", ":", "# Verify that an Unreal project or plugin exists in the specified directory", "descriptor", "=", "self", ".", "getDescriptor", "(", "dir...
Packages a build of the Unreal project or plugin in the specified directory
[ "Packages", "a", "build", "of", "the", "Unreal", "project", "or", "plugin", "in", "the", "specified", "directory" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L413-L425
18,269
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase.runAutomationCommands
def runAutomationCommands(self, projectFile, commands, capture=False): ''' Invokes the Automation Test commandlet for the specified project with the supplied automation test commands ''' # IMPORTANT IMPLEMENTATION NOTE: # We need to format the command as a string and execute it using a shell in order to # ensure the "-ExecCmds" argument will be parsed correctly under Windows. This is because # the WinMain() function uses GetCommandLineW() to retrieve the raw command-line string, # rather than using an argv-style structure. The string is then passed to FParse::Value(), # which checks for the presence of a quote character after the equals sign to determine if # whitespace should be stripped or preserved. Without the quote character, the spaces in the # argument payload will be stripped out, corrupting our list of automation commands and # preventing them from executing correctly. command = '{} {}'.format(Utility.escapePathForShell(self.getEditorBinary(True)), Utility.escapePathForShell(projectFile)) command += ' -game -buildmachine -stdout -fullstdoutlogoutput -forcelogflush -unattended -nopause -nullrhi -nosplash' command += ' -ExecCmds="automation {};quit"'.format(';'.join(commands)) if capture == True: return Utility.capture(command, shell=True) else: Utility.run(command, shell=True)
python
def runAutomationCommands(self, projectFile, commands, capture=False): ''' Invokes the Automation Test commandlet for the specified project with the supplied automation test commands ''' # IMPORTANT IMPLEMENTATION NOTE: # We need to format the command as a string and execute it using a shell in order to # ensure the "-ExecCmds" argument will be parsed correctly under Windows. This is because # the WinMain() function uses GetCommandLineW() to retrieve the raw command-line string, # rather than using an argv-style structure. The string is then passed to FParse::Value(), # which checks for the presence of a quote character after the equals sign to determine if # whitespace should be stripped or preserved. Without the quote character, the spaces in the # argument payload will be stripped out, corrupting our list of automation commands and # preventing them from executing correctly. command = '{} {}'.format(Utility.escapePathForShell(self.getEditorBinary(True)), Utility.escapePathForShell(projectFile)) command += ' -game -buildmachine -stdout -fullstdoutlogoutput -forcelogflush -unattended -nopause -nullrhi -nosplash' command += ' -ExecCmds="automation {};quit"'.format(';'.join(commands)) if capture == True: return Utility.capture(command, shell=True) else: Utility.run(command, shell=True)
[ "def", "runAutomationCommands", "(", "self", ",", "projectFile", ",", "commands", ",", "capture", "=", "False", ")", ":", "# IMPORTANT IMPLEMENTATION NOTE:", "# We need to format the command as a string and execute it using a shell in order to", "# ensure the \"-ExecCmds\" argument w...
Invokes the Automation Test commandlet for the specified project with the supplied automation test commands
[ "Invokes", "the", "Automation", "Test", "commandlet", "for", "the", "specified", "project", "with", "the", "supplied", "automation", "test", "commands" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L427-L449
18,270
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase._getEngineVersionDetails
def _getEngineVersionDetails(self): """ Parses the JSON version details for the latest installed version of UE4 """ versionFile = os.path.join(self.getEngineRoot(), 'Engine', 'Build', 'Build.version') return json.loads(Utility.readFile(versionFile))
python
def _getEngineVersionDetails(self): versionFile = os.path.join(self.getEngineRoot(), 'Engine', 'Build', 'Build.version') return json.loads(Utility.readFile(versionFile))
[ "def", "_getEngineVersionDetails", "(", "self", ")", ":", "versionFile", "=", "os", ".", "path", ".", "join", "(", "self", ".", "getEngineRoot", "(", ")", ",", "'Engine'", ",", "'Build'", ",", "'Build.version'", ")", "return", "json", ".", "loads", "(", ...
Parses the JSON version details for the latest installed version of UE4
[ "Parses", "the", "JSON", "version", "details", "for", "the", "latest", "installed", "version", "of", "UE4" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L555-L560
18,271
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase._getEngineVersionHash
def _getEngineVersionHash(self): """ Computes the SHA-256 hash of the JSON version details for the latest installed version of UE4 """ versionDetails = self._getEngineVersionDetails() hash = hashlib.sha256() hash.update(json.dumps(versionDetails, sort_keys=True, indent=0).encode('utf-8')) return hash.hexdigest()
python
def _getEngineVersionHash(self): versionDetails = self._getEngineVersionDetails() hash = hashlib.sha256() hash.update(json.dumps(versionDetails, sort_keys=True, indent=0).encode('utf-8')) return hash.hexdigest()
[ "def", "_getEngineVersionHash", "(", "self", ")", ":", "versionDetails", "=", "self", ".", "_getEngineVersionDetails", "(", ")", "hash", "=", "hashlib", ".", "sha256", "(", ")", "hash", ".", "update", "(", "json", ".", "dumps", "(", "versionDetails", ",", ...
Computes the SHA-256 hash of the JSON version details for the latest installed version of UE4
[ "Computes", "the", "SHA", "-", "256", "hash", "of", "the", "JSON", "version", "details", "for", "the", "latest", "installed", "version", "of", "UE4" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L562-L569
18,272
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase._runUnrealBuildTool
def _runUnrealBuildTool(self, target, platform, configuration, args, capture=False): """ Invokes UnrealBuildTool with the specified parameters """ platform = self._transformBuildToolPlatform(platform) arguments = [self.getBuildScript(), target, platform, configuration] + args if capture == True: return Utility.capture(arguments, cwd=self.getEngineRoot(), raiseOnError=True) else: Utility.run(arguments, cwd=self.getEngineRoot(), raiseOnError=True)
python
def _runUnrealBuildTool(self, target, platform, configuration, args, capture=False): platform = self._transformBuildToolPlatform(platform) arguments = [self.getBuildScript(), target, platform, configuration] + args if capture == True: return Utility.capture(arguments, cwd=self.getEngineRoot(), raiseOnError=True) else: Utility.run(arguments, cwd=self.getEngineRoot(), raiseOnError=True)
[ "def", "_runUnrealBuildTool", "(", "self", ",", "target", ",", "platform", ",", "configuration", ",", "args", ",", "capture", "=", "False", ")", ":", "platform", "=", "self", ".", "_transformBuildToolPlatform", "(", "platform", ")", "arguments", "=", "[", "s...
Invokes UnrealBuildTool with the specified parameters
[ "Invokes", "UnrealBuildTool", "with", "the", "specified", "parameters" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L607-L616
18,273
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase._getUE4BuildInterrogator
def _getUE4BuildInterrogator(self): """ Uses UE4BuildInterrogator to interrogate UnrealBuildTool about third-party library details """ ubtLambda = lambda target, platform, config, args: self._runUnrealBuildTool(target, platform, config, args, True) interrogator = UE4BuildInterrogator(self.getEngineRoot(), self._getEngineVersionDetails(), self._getEngineVersionHash(), ubtLambda) return interrogator
python
def _getUE4BuildInterrogator(self): ubtLambda = lambda target, platform, config, args: self._runUnrealBuildTool(target, platform, config, args, True) interrogator = UE4BuildInterrogator(self.getEngineRoot(), self._getEngineVersionDetails(), self._getEngineVersionHash(), ubtLambda) return interrogator
[ "def", "_getUE4BuildInterrogator", "(", "self", ")", ":", "ubtLambda", "=", "lambda", "target", ",", "platform", ",", "config", ",", "args", ":", "self", ".", "_runUnrealBuildTool", "(", "target", ",", "platform", ",", "config", ",", "args", ",", "True", "...
Uses UE4BuildInterrogator to interrogate UnrealBuildTool about third-party library details
[ "Uses", "UE4BuildInterrogator", "to", "interrogate", "UnrealBuildTool", "about", "third", "-", "party", "library", "details" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L618-L624
18,274
adamrehn/ue4cli
ue4cli/JsonDataManager.py
JsonDataManager.getKey
def getKey(self, key): """ Retrieves the value for the specified dictionary key """ data = self.getDictionary() if key in data: return data[key] else: return None
python
def getKey(self, key): data = self.getDictionary() if key in data: return data[key] else: return None
[ "def", "getKey", "(", "self", ",", "key", ")", ":", "data", "=", "self", ".", "getDictionary", "(", ")", "if", "key", "in", "data", ":", "return", "data", "[", "key", "]", "else", ":", "return", "None" ]
Retrieves the value for the specified dictionary key
[ "Retrieves", "the", "value", "for", "the", "specified", "dictionary", "key" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/JsonDataManager.py#L15-L23
18,275
adamrehn/ue4cli
ue4cli/JsonDataManager.py
JsonDataManager.getDictionary
def getDictionary(self): """ Retrieves the entire data dictionary """ if os.path.exists(self.jsonFile): return json.loads(Utility.readFile(self.jsonFile)) else: return {}
python
def getDictionary(self): if os.path.exists(self.jsonFile): return json.loads(Utility.readFile(self.jsonFile)) else: return {}
[ "def", "getDictionary", "(", "self", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "jsonFile", ")", ":", "return", "json", ".", "loads", "(", "Utility", ".", "readFile", "(", "self", ".", "jsonFile", ")", ")", "else", ":", "re...
Retrieves the entire data dictionary
[ "Retrieves", "the", "entire", "data", "dictionary" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/JsonDataManager.py#L25-L32
18,276
adamrehn/ue4cli
ue4cli/JsonDataManager.py
JsonDataManager.setKey
def setKey(self, key, value): """ Sets the value for the specified dictionary key """ data = self.getDictionary() data[key] = value self.setDictionary(data)
python
def setKey(self, key, value): data = self.getDictionary() data[key] = value self.setDictionary(data)
[ "def", "setKey", "(", "self", ",", "key", ",", "value", ")", ":", "data", "=", "self", ".", "getDictionary", "(", ")", "data", "[", "key", "]", "=", "value", "self", ".", "setDictionary", "(", "data", ")" ]
Sets the value for the specified dictionary key
[ "Sets", "the", "value", "for", "the", "specified", "dictionary", "key" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/JsonDataManager.py#L34-L40
18,277
adamrehn/ue4cli
ue4cli/JsonDataManager.py
JsonDataManager.setDictionary
def setDictionary(self, data): """ Overwrites the entire dictionary """ # Create the directory containing the JSON file if it doesn't already exist jsonDir = os.path.dirname(self.jsonFile) if os.path.exists(jsonDir) == False: os.makedirs(jsonDir) # Store the dictionary Utility.writeFile(self.jsonFile, json.dumps(data))
python
def setDictionary(self, data): # Create the directory containing the JSON file if it doesn't already exist jsonDir = os.path.dirname(self.jsonFile) if os.path.exists(jsonDir) == False: os.makedirs(jsonDir) # Store the dictionary Utility.writeFile(self.jsonFile, json.dumps(data))
[ "def", "setDictionary", "(", "self", ",", "data", ")", ":", "# Create the directory containing the JSON file if it doesn't already exist", "jsonDir", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "jsonFile", ")", "if", "os", ".", "path", ".", "exists",...
Overwrites the entire dictionary
[ "Overwrites", "the", "entire", "dictionary" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/JsonDataManager.py#L42-L53
18,278
adamrehn/ue4cli
ue4cli/UE4BuildInterrogator.py
UE4BuildInterrogator.list
def list(self, platformIdentifier, configuration, libOverrides = {}): """ Returns the list of supported UE4-bundled third-party libraries """ modules = self._getThirdPartyLibs(platformIdentifier, configuration) return sorted([m['Name'] for m in modules] + [key for key in libOverrides])
python
def list(self, platformIdentifier, configuration, libOverrides = {}): modules = self._getThirdPartyLibs(platformIdentifier, configuration) return sorted([m['Name'] for m in modules] + [key for key in libOverrides])
[ "def", "list", "(", "self", ",", "platformIdentifier", ",", "configuration", ",", "libOverrides", "=", "{", "}", ")", ":", "modules", "=", "self", ".", "_getThirdPartyLibs", "(", "platformIdentifier", ",", "configuration", ")", "return", "sorted", "(", "[", ...
Returns the list of supported UE4-bundled third-party libraries
[ "Returns", "the", "list", "of", "supported", "UE4", "-", "bundled", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UE4BuildInterrogator.py#L16-L21
18,279
adamrehn/ue4cli
ue4cli/UE4BuildInterrogator.py
UE4BuildInterrogator.interrogate
def interrogate(self, platformIdentifier, configuration, libraries, libOverrides = {}): """ Interrogates UnrealBuildTool about the build flags for the specified third-party libraries """ # Determine which libraries need their modules parsed by UBT, and which are override-only libModules = list([lib for lib in libraries if lib not in libOverrides]) # Check that we have at least one module to parse details = ThirdPartyLibraryDetails() if len(libModules) > 0: # Retrieve the list of third-party library modules from UnrealBuildTool modules = self._getThirdPartyLibs(platformIdentifier, configuration) # Filter the list of modules to include only those that were requested modules = [m for m in modules if m['Name'] in libModules] # Emit a warning if any of the requested modules are not supported names = [m['Name'] for m in modules] unsupported = ['"' + m + '"' for m in libModules if m not in names] if len(unsupported) > 0: Utility.printStderr('Warning: unsupported libraries ' + ','.join(unsupported)) # Some libraries are listed as just the filename without the leading directory (especially prevalent under Windows) for module in modules: if len(module['PublicAdditionalLibraries']) > 0 and len(module['PublicLibraryPaths']) > 0: libPath = (self._absolutePaths(module['PublicLibraryPaths']))[0] libs = list([lib.replace('\\', '/') for lib in module['PublicAdditionalLibraries']]) libs = list([os.path.join(libPath, lib) if '/' not in lib else lib for lib in libs]) module['PublicAdditionalLibraries'] = libs # Flatten the lists of paths fields = [ 'Directory', 'PublicAdditionalLibraries', 'PublicLibraryPaths', 'PublicSystemIncludePaths', 'PublicIncludePaths', 'PrivateIncludePaths', 'PublicDefinitions' ] flattened = {} for field in fields: transform = (lambda l: self._absolutePaths(l)) if field != 'Definitions' else None flattened[field] = self._flatten(field, modules, transform) # Compose the prefix directories from the module root directories, the header and library paths, and their direct parent directories libraryDirectories = flattened['PublicLibraryPaths'] headerDirectories = flattened['PublicSystemIncludePaths'] + flattened['PublicIncludePaths'] + flattened['PrivateIncludePaths'] modulePaths = flattened['Directory'] prefixDirectories = list(set(flattened['Directory'] + headerDirectories + libraryDirectories + [os.path.dirname(p) for p in headerDirectories + libraryDirectories])) # Wrap the results in a ThirdPartyLibraryDetails instance, converting any relative directory paths into absolute ones details = ThirdPartyLibraryDetails( prefixDirs = prefixDirectories, includeDirs = headerDirectories, linkDirs = libraryDirectories, definitions = flattened['PublicDefinitions'], libs = flattened['PublicAdditionalLibraries'] ) # Apply any overrides overridesToApply = list([libOverrides[lib] for lib in libraries if lib in libOverrides]) for override in overridesToApply: details.merge(override) return details
python
def interrogate(self, platformIdentifier, configuration, libraries, libOverrides = {}): # Determine which libraries need their modules parsed by UBT, and which are override-only libModules = list([lib for lib in libraries if lib not in libOverrides]) # Check that we have at least one module to parse details = ThirdPartyLibraryDetails() if len(libModules) > 0: # Retrieve the list of third-party library modules from UnrealBuildTool modules = self._getThirdPartyLibs(platformIdentifier, configuration) # Filter the list of modules to include only those that were requested modules = [m for m in modules if m['Name'] in libModules] # Emit a warning if any of the requested modules are not supported names = [m['Name'] for m in modules] unsupported = ['"' + m + '"' for m in libModules if m not in names] if len(unsupported) > 0: Utility.printStderr('Warning: unsupported libraries ' + ','.join(unsupported)) # Some libraries are listed as just the filename without the leading directory (especially prevalent under Windows) for module in modules: if len(module['PublicAdditionalLibraries']) > 0 and len(module['PublicLibraryPaths']) > 0: libPath = (self._absolutePaths(module['PublicLibraryPaths']))[0] libs = list([lib.replace('\\', '/') for lib in module['PublicAdditionalLibraries']]) libs = list([os.path.join(libPath, lib) if '/' not in lib else lib for lib in libs]) module['PublicAdditionalLibraries'] = libs # Flatten the lists of paths fields = [ 'Directory', 'PublicAdditionalLibraries', 'PublicLibraryPaths', 'PublicSystemIncludePaths', 'PublicIncludePaths', 'PrivateIncludePaths', 'PublicDefinitions' ] flattened = {} for field in fields: transform = (lambda l: self._absolutePaths(l)) if field != 'Definitions' else None flattened[field] = self._flatten(field, modules, transform) # Compose the prefix directories from the module root directories, the header and library paths, and their direct parent directories libraryDirectories = flattened['PublicLibraryPaths'] headerDirectories = flattened['PublicSystemIncludePaths'] + flattened['PublicIncludePaths'] + flattened['PrivateIncludePaths'] modulePaths = flattened['Directory'] prefixDirectories = list(set(flattened['Directory'] + headerDirectories + libraryDirectories + [os.path.dirname(p) for p in headerDirectories + libraryDirectories])) # Wrap the results in a ThirdPartyLibraryDetails instance, converting any relative directory paths into absolute ones details = ThirdPartyLibraryDetails( prefixDirs = prefixDirectories, includeDirs = headerDirectories, linkDirs = libraryDirectories, definitions = flattened['PublicDefinitions'], libs = flattened['PublicAdditionalLibraries'] ) # Apply any overrides overridesToApply = list([libOverrides[lib] for lib in libraries if lib in libOverrides]) for override in overridesToApply: details.merge(override) return details
[ "def", "interrogate", "(", "self", ",", "platformIdentifier", ",", "configuration", ",", "libraries", ",", "libOverrides", "=", "{", "}", ")", ":", "# Determine which libraries need their modules parsed by UBT, and which are override-only", "libModules", "=", "list", "(", ...
Interrogates UnrealBuildTool about the build flags for the specified third-party libraries
[ "Interrogates", "UnrealBuildTool", "about", "the", "build", "flags", "for", "the", "specified", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UE4BuildInterrogator.py#L23-L90
18,280
adamrehn/ue4cli
ue4cli/UE4BuildInterrogator.py
UE4BuildInterrogator._flatten
def _flatten(self, field, items, transform = None): """ Extracts the entry `field` from each item in the supplied iterable, flattening any nested lists """ # Retrieve the value for each item in the iterable values = [item[field] for item in items] # Flatten any nested lists flattened = [] for value in values: flattened.extend([value] if isinstance(value, str) else value) # Apply any supplied transformation function return transform(flattened) if transform != None else flattened
python
def _flatten(self, field, items, transform = None): # Retrieve the value for each item in the iterable values = [item[field] for item in items] # Flatten any nested lists flattened = [] for value in values: flattened.extend([value] if isinstance(value, str) else value) # Apply any supplied transformation function return transform(flattened) if transform != None else flattened
[ "def", "_flatten", "(", "self", ",", "field", ",", "items", ",", "transform", "=", "None", ")", ":", "# Retrieve the value for each item in the iterable", "values", "=", "[", "item", "[", "field", "]", "for", "item", "in", "items", "]", "# Flatten any nested lis...
Extracts the entry `field` from each item in the supplied iterable, flattening any nested lists
[ "Extracts", "the", "entry", "field", "from", "each", "item", "in", "the", "supplied", "iterable", "flattening", "any", "nested", "lists" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UE4BuildInterrogator.py#L103-L117
18,281
adamrehn/ue4cli
ue4cli/UE4BuildInterrogator.py
UE4BuildInterrogator._getThirdPartyLibs
def _getThirdPartyLibs(self, platformIdentifier, configuration): """ Runs UnrealBuildTool in JSON export mode and extracts the list of third-party libraries """ # If we have previously cached the library list for the current engine version, use the cached data cachedList = CachedDataManager.getCachedDataKey(self.engineVersionHash, 'ThirdPartyLibraries') if cachedList != None: return cachedList # Create a temp directory to hold the JSON file tempDir = tempfile.mkdtemp() jsonFile = os.path.join(tempDir, 'ubt_output.json') # Installed Builds of the Engine only contain a small handful of third-party libraries, rather than the full set # included in a source build of the Engine. However, if the ThirdParty directory from a source build is copied # into an Installed Build and the `InstalledBuild.txt` sentinel file is temporarily renamed, we can get the best # of both worlds and utilise the full set of third-party libraries. Enable this sentinel renaming behaviour only # if you have copied the ThirdParty directory from a source build into your Installed Build, or else the UBT # command will fail trying to rebuild UnrealHeaderTool. sentinelFile = os.path.join(self.engineRoot, 'Engine', 'Build', 'InstalledBuild.txt') sentinelBackup = sentinelFile + '.bak' renameSentinel = os.path.exists(sentinelFile) and os.environ.get('UE4CLI_SENTINEL_RENAME', '0') == '1' if renameSentinel == True: shutil.move(sentinelFile, sentinelBackup) # Invoke UnrealBuildTool in JSON export mode (make sure we specify gathering mode, since this is a prerequisite of JSON export) # (Ensure we always perform sentinel file cleanup even when errors occur) try: args = ['-Mode=JsonExport', '-OutputFile=' +jsonFile ] if self.engineVersion['MinorVersion'] >= 22 else ['-gather', '-jsonexport=' + jsonFile, '-SkipBuild'] self.runUBTFunc('UE4Editor', platformIdentifier, configuration, args) finally: if renameSentinel == True: shutil.move(sentinelBackup, sentinelFile) # Parse the JSON output result = json.loads(Utility.readFile(jsonFile)) # Extract the list of third-party library modules # (Note that since UE4.21, modules no longer have a "Type" field, so we must # rely on the "Directory" field filter below to identify third-party libraries) modules = [result['Modules'][key] for key in result['Modules']] # Filter out any modules from outside the Engine/Source/ThirdParty directory thirdPartyRoot = os.path.join(self.engineRoot, 'Engine', 'Source', 'ThirdParty') thirdparty = list([m for m in modules if thirdPartyRoot in m['Directory']]) # Remove the temp directory try: shutil.rmtree(tempDir) except: pass # Cache the list of libraries for use by subsequent runs CachedDataManager.setCachedDataKey(self.engineVersionHash, 'ThirdPartyLibraries', thirdparty) return thirdparty
python
def _getThirdPartyLibs(self, platformIdentifier, configuration): # If we have previously cached the library list for the current engine version, use the cached data cachedList = CachedDataManager.getCachedDataKey(self.engineVersionHash, 'ThirdPartyLibraries') if cachedList != None: return cachedList # Create a temp directory to hold the JSON file tempDir = tempfile.mkdtemp() jsonFile = os.path.join(tempDir, 'ubt_output.json') # Installed Builds of the Engine only contain a small handful of third-party libraries, rather than the full set # included in a source build of the Engine. However, if the ThirdParty directory from a source build is copied # into an Installed Build and the `InstalledBuild.txt` sentinel file is temporarily renamed, we can get the best # of both worlds and utilise the full set of third-party libraries. Enable this sentinel renaming behaviour only # if you have copied the ThirdParty directory from a source build into your Installed Build, or else the UBT # command will fail trying to rebuild UnrealHeaderTool. sentinelFile = os.path.join(self.engineRoot, 'Engine', 'Build', 'InstalledBuild.txt') sentinelBackup = sentinelFile + '.bak' renameSentinel = os.path.exists(sentinelFile) and os.environ.get('UE4CLI_SENTINEL_RENAME', '0') == '1' if renameSentinel == True: shutil.move(sentinelFile, sentinelBackup) # Invoke UnrealBuildTool in JSON export mode (make sure we specify gathering mode, since this is a prerequisite of JSON export) # (Ensure we always perform sentinel file cleanup even when errors occur) try: args = ['-Mode=JsonExport', '-OutputFile=' +jsonFile ] if self.engineVersion['MinorVersion'] >= 22 else ['-gather', '-jsonexport=' + jsonFile, '-SkipBuild'] self.runUBTFunc('UE4Editor', platformIdentifier, configuration, args) finally: if renameSentinel == True: shutil.move(sentinelBackup, sentinelFile) # Parse the JSON output result = json.loads(Utility.readFile(jsonFile)) # Extract the list of third-party library modules # (Note that since UE4.21, modules no longer have a "Type" field, so we must # rely on the "Directory" field filter below to identify third-party libraries) modules = [result['Modules'][key] for key in result['Modules']] # Filter out any modules from outside the Engine/Source/ThirdParty directory thirdPartyRoot = os.path.join(self.engineRoot, 'Engine', 'Source', 'ThirdParty') thirdparty = list([m for m in modules if thirdPartyRoot in m['Directory']]) # Remove the temp directory try: shutil.rmtree(tempDir) except: pass # Cache the list of libraries for use by subsequent runs CachedDataManager.setCachedDataKey(self.engineVersionHash, 'ThirdPartyLibraries', thirdparty) return thirdparty
[ "def", "_getThirdPartyLibs", "(", "self", ",", "platformIdentifier", ",", "configuration", ")", ":", "# If we have previously cached the library list for the current engine version, use the cached data", "cachedList", "=", "CachedDataManager", ".", "getCachedDataKey", "(", "self", ...
Runs UnrealBuildTool in JSON export mode and extracts the list of third-party libraries
[ "Runs", "UnrealBuildTool", "in", "JSON", "export", "mode", "and", "extracts", "the", "list", "of", "third", "-", "party", "libraries" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UE4BuildInterrogator.py#L119-L175
18,282
adamrehn/ue4cli
ue4cli/CMakeCustomFlags.py
CMakeCustomFlags.processLibraryDetails
def processLibraryDetails(details): """ Processes the supplied ThirdPartyLibraryDetails instance and sets any custom CMake flags """ # If the header include directories list contains any directories we have flags for, add them for includeDir in details.includeDirs: # If the directory path matches any of the substrings in our list, generate the relevant flags for pattern in CUSTOM_FLAGS_FOR_INCLUDE_DIRS: if pattern in includeDir: flag = '-D' + CUSTOM_FLAGS_FOR_INCLUDE_DIRS[pattern] + '=' + includeDir details.cmakeFlags.append(flag) # If the libraries list contains any libs we have flags for, add them for lib in details.libs: # Extract the name of the library from the filename # (We remove any "lib" prefix or numerical suffix) filename = os.path.basename(lib) (name, ext) = os.path.splitext(filename) libName = name.replace('lib', '') if name.startswith('lib') else name libName = libName.rstrip('_-1234567890') # If the library name matches one in our list, generate its flag if libName in CUSTOM_FLAGS_FOR_LIBS: flag = '-D' + CUSTOM_FLAGS_FOR_LIBS[libName] + '=' + lib details.cmakeFlags.append(flag)
python
def processLibraryDetails(details): # If the header include directories list contains any directories we have flags for, add them for includeDir in details.includeDirs: # If the directory path matches any of the substrings in our list, generate the relevant flags for pattern in CUSTOM_FLAGS_FOR_INCLUDE_DIRS: if pattern in includeDir: flag = '-D' + CUSTOM_FLAGS_FOR_INCLUDE_DIRS[pattern] + '=' + includeDir details.cmakeFlags.append(flag) # If the libraries list contains any libs we have flags for, add them for lib in details.libs: # Extract the name of the library from the filename # (We remove any "lib" prefix or numerical suffix) filename = os.path.basename(lib) (name, ext) = os.path.splitext(filename) libName = name.replace('lib', '') if name.startswith('lib') else name libName = libName.rstrip('_-1234567890') # If the library name matches one in our list, generate its flag if libName in CUSTOM_FLAGS_FOR_LIBS: flag = '-D' + CUSTOM_FLAGS_FOR_LIBS[libName] + '=' + lib details.cmakeFlags.append(flag)
[ "def", "processLibraryDetails", "(", "details", ")", ":", "# If the header include directories list contains any directories we have flags for, add them", "for", "includeDir", "in", "details", ".", "includeDirs", ":", "# If the directory path matches any of the substrings in our list, ge...
Processes the supplied ThirdPartyLibraryDetails instance and sets any custom CMake flags
[ "Processes", "the", "supplied", "ThirdPartyLibraryDetails", "instance", "and", "sets", "any", "custom", "CMake", "flags" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/CMakeCustomFlags.py#L19-L46
18,283
adamrehn/ue4cli
ue4cli/PluginManager.py
PluginManager.getPlugins
def getPlugins(): """ Returns the list of valid ue4cli plugins """ # Retrieve the list of detected entry points in the ue4cli.plugins group plugins = { entry_point.name: entry_point.load() for entry_point in pkg_resources.iter_entry_points('ue4cli.plugins') } # Filter out any invalid plugins plugins = { name: plugins[name] for name in plugins if 'action' in plugins[name] and 'description' in plugins[name] and 'args' in plugins[name] and callable(plugins[name]['action']) == True and len(signature(plugins[name]['action']).parameters) == 2 } return plugins
python
def getPlugins(): # Retrieve the list of detected entry points in the ue4cli.plugins group plugins = { entry_point.name: entry_point.load() for entry_point in pkg_resources.iter_entry_points('ue4cli.plugins') } # Filter out any invalid plugins plugins = { name: plugins[name] for name in plugins if 'action' in plugins[name] and 'description' in plugins[name] and 'args' in plugins[name] and callable(plugins[name]['action']) == True and len(signature(plugins[name]['action']).parameters) == 2 } return plugins
[ "def", "getPlugins", "(", ")", ":", "# Retrieve the list of detected entry points in the ue4cli.plugins group", "plugins", "=", "{", "entry_point", ".", "name", ":", "entry_point", ".", "load", "(", ")", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_poin...
Returns the list of valid ue4cli plugins
[ "Returns", "the", "list", "of", "valid", "ue4cli", "plugins" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/PluginManager.py#L10-L34
18,284
adamrehn/ue4cli
ue4cli/ThirdPartyLibraryDetails.py
ThirdPartyLibraryDetails.getCompilerFlags
def getCompilerFlags(self, engineRoot, fmt): """ Constructs the compiler flags string for building against this library """ return Utility.join( fmt.delim, self.prefixedStrings(self.definitionPrefix, self.definitions, engineRoot) + self.prefixedStrings(self.includeDirPrefix, self.includeDirs, engineRoot) + self.resolveRoot(self.cxxFlags, engineRoot), fmt.quotes )
python
def getCompilerFlags(self, engineRoot, fmt): return Utility.join( fmt.delim, self.prefixedStrings(self.definitionPrefix, self.definitions, engineRoot) + self.prefixedStrings(self.includeDirPrefix, self.includeDirs, engineRoot) + self.resolveRoot(self.cxxFlags, engineRoot), fmt.quotes )
[ "def", "getCompilerFlags", "(", "self", ",", "engineRoot", ",", "fmt", ")", ":", "return", "Utility", ".", "join", "(", "fmt", ".", "delim", ",", "self", ".", "prefixedStrings", "(", "self", ".", "definitionPrefix", ",", "self", ".", "definitions", ",", ...
Constructs the compiler flags string for building against this library
[ "Constructs", "the", "compiler", "flags", "string", "for", "building", "against", "this", "library" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ThirdPartyLibraryDetails.py#L71-L81
18,285
adamrehn/ue4cli
ue4cli/ThirdPartyLibraryDetails.py
ThirdPartyLibraryDetails.getLinkerFlags
def getLinkerFlags(self, engineRoot, fmt, includeLibs=True): """ Constructs the linker flags string for building against this library """ components = self.resolveRoot(self.ldFlags, engineRoot) if includeLibs == True: components.extend(self.prefixedStrings(self.linkerDirPrefix, self.linkDirs, engineRoot)) components.extend(self.resolveRoot(self.libs, engineRoot)) return Utility.join(fmt.delim, components, fmt.quotes)
python
def getLinkerFlags(self, engineRoot, fmt, includeLibs=True): components = self.resolveRoot(self.ldFlags, engineRoot) if includeLibs == True: components.extend(self.prefixedStrings(self.linkerDirPrefix, self.linkDirs, engineRoot)) components.extend(self.resolveRoot(self.libs, engineRoot)) return Utility.join(fmt.delim, components, fmt.quotes)
[ "def", "getLinkerFlags", "(", "self", ",", "engineRoot", ",", "fmt", ",", "includeLibs", "=", "True", ")", ":", "components", "=", "self", ".", "resolveRoot", "(", "self", ".", "ldFlags", ",", "engineRoot", ")", "if", "includeLibs", "==", "True", ":", "c...
Constructs the linker flags string for building against this library
[ "Constructs", "the", "linker", "flags", "string", "for", "building", "against", "this", "library" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ThirdPartyLibraryDetails.py#L83-L92
18,286
adamrehn/ue4cli
ue4cli/ThirdPartyLibraryDetails.py
ThirdPartyLibraryDetails.getPrefixDirectories
def getPrefixDirectories(self, engineRoot, delimiter=' '): """ Returns the list of prefix directories for this library, joined using the specified delimiter """ return delimiter.join(self.resolveRoot(self.prefixDirs, engineRoot))
python
def getPrefixDirectories(self, engineRoot, delimiter=' '): return delimiter.join(self.resolveRoot(self.prefixDirs, engineRoot))
[ "def", "getPrefixDirectories", "(", "self", ",", "engineRoot", ",", "delimiter", "=", "' '", ")", ":", "return", "delimiter", ".", "join", "(", "self", ".", "resolveRoot", "(", "self", ".", "prefixDirs", ",", "engineRoot", ")", ")" ]
Returns the list of prefix directories for this library, joined using the specified delimiter
[ "Returns", "the", "list", "of", "prefix", "directories", "for", "this", "library", "joined", "using", "the", "specified", "delimiter" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ThirdPartyLibraryDetails.py#L94-L98
18,287
adamrehn/ue4cli
ue4cli/ThirdPartyLibraryDetails.py
ThirdPartyLibraryDetails.getIncludeDirectories
def getIncludeDirectories(self, engineRoot, delimiter=' '): """ Returns the list of include directories for this library, joined using the specified delimiter """ return delimiter.join(self.resolveRoot(self.includeDirs, engineRoot))
python
def getIncludeDirectories(self, engineRoot, delimiter=' '): return delimiter.join(self.resolveRoot(self.includeDirs, engineRoot))
[ "def", "getIncludeDirectories", "(", "self", ",", "engineRoot", ",", "delimiter", "=", "' '", ")", ":", "return", "delimiter", ".", "join", "(", "self", ".", "resolveRoot", "(", "self", ".", "includeDirs", ",", "engineRoot", ")", ")" ]
Returns the list of include directories for this library, joined using the specified delimiter
[ "Returns", "the", "list", "of", "include", "directories", "for", "this", "library", "joined", "using", "the", "specified", "delimiter" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ThirdPartyLibraryDetails.py#L100-L104
18,288
adamrehn/ue4cli
ue4cli/ThirdPartyLibraryDetails.py
ThirdPartyLibraryDetails.getLinkerDirectories
def getLinkerDirectories(self, engineRoot, delimiter=' '): """ Returns the list of linker directories for this library, joined using the specified delimiter """ return delimiter.join(self.resolveRoot(self.linkDirs, engineRoot))
python
def getLinkerDirectories(self, engineRoot, delimiter=' '): return delimiter.join(self.resolveRoot(self.linkDirs, engineRoot))
[ "def", "getLinkerDirectories", "(", "self", ",", "engineRoot", ",", "delimiter", "=", "' '", ")", ":", "return", "delimiter", ".", "join", "(", "self", ".", "resolveRoot", "(", "self", ".", "linkDirs", ",", "engineRoot", ")", ")" ]
Returns the list of linker directories for this library, joined using the specified delimiter
[ "Returns", "the", "list", "of", "linker", "directories", "for", "this", "library", "joined", "using", "the", "specified", "delimiter" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ThirdPartyLibraryDetails.py#L106-L110
18,289
adamrehn/ue4cli
ue4cli/ThirdPartyLibraryDetails.py
ThirdPartyLibraryDetails.getLibraryFiles
def getLibraryFiles(self, engineRoot, delimiter=' '): """ Returns the list of library files for this library, joined using the specified delimiter """ return delimiter.join(self.resolveRoot(self.libs, engineRoot))
python
def getLibraryFiles(self, engineRoot, delimiter=' '): return delimiter.join(self.resolveRoot(self.libs, engineRoot))
[ "def", "getLibraryFiles", "(", "self", ",", "engineRoot", ",", "delimiter", "=", "' '", ")", ":", "return", "delimiter", ".", "join", "(", "self", ".", "resolveRoot", "(", "self", ".", "libs", ",", "engineRoot", ")", ")" ]
Returns the list of library files for this library, joined using the specified delimiter
[ "Returns", "the", "list", "of", "library", "files", "for", "this", "library", "joined", "using", "the", "specified", "delimiter" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ThirdPartyLibraryDetails.py#L112-L116
18,290
adamrehn/ue4cli
ue4cli/ThirdPartyLibraryDetails.py
ThirdPartyLibraryDetails.getPreprocessorDefinitions
def getPreprocessorDefinitions(self, engineRoot, delimiter=' '): """ Returns the list of preprocessor definitions for this library, joined using the specified delimiter """ return delimiter.join(self.resolveRoot(self.definitions, engineRoot))
python
def getPreprocessorDefinitions(self, engineRoot, delimiter=' '): return delimiter.join(self.resolveRoot(self.definitions, engineRoot))
[ "def", "getPreprocessorDefinitions", "(", "self", ",", "engineRoot", ",", "delimiter", "=", "' '", ")", ":", "return", "delimiter", ".", "join", "(", "self", ".", "resolveRoot", "(", "self", ".", "definitions", ",", "engineRoot", ")", ")" ]
Returns the list of preprocessor definitions for this library, joined using the specified delimiter
[ "Returns", "the", "list", "of", "preprocessor", "definitions", "for", "this", "library", "joined", "using", "the", "specified", "delimiter" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ThirdPartyLibraryDetails.py#L118-L122
18,291
adamrehn/ue4cli
ue4cli/ThirdPartyLibraryDetails.py
ThirdPartyLibraryDetails.getCMakeFlags
def getCMakeFlags(self, engineRoot, fmt): """ Constructs the CMake invocation flags string for building against this library """ return Utility.join( fmt.delim, [ '-DCMAKE_PREFIX_PATH=' + self.getPrefixDirectories(engineRoot, ';'), '-DCMAKE_INCLUDE_PATH=' + self.getIncludeDirectories(engineRoot, ';'), '-DCMAKE_LIBRARY_PATH=' + self.getLinkerDirectories(engineRoot, ';'), ] + self.resolveRoot(self.cmakeFlags, engineRoot), fmt.quotes )
python
def getCMakeFlags(self, engineRoot, fmt): return Utility.join( fmt.delim, [ '-DCMAKE_PREFIX_PATH=' + self.getPrefixDirectories(engineRoot, ';'), '-DCMAKE_INCLUDE_PATH=' + self.getIncludeDirectories(engineRoot, ';'), '-DCMAKE_LIBRARY_PATH=' + self.getLinkerDirectories(engineRoot, ';'), ] + self.resolveRoot(self.cmakeFlags, engineRoot), fmt.quotes )
[ "def", "getCMakeFlags", "(", "self", ",", "engineRoot", ",", "fmt", ")", ":", "return", "Utility", ".", "join", "(", "fmt", ".", "delim", ",", "[", "'-DCMAKE_PREFIX_PATH='", "+", "self", ".", "getPrefixDirectories", "(", "engineRoot", ",", "';'", ")", ",",...
Constructs the CMake invocation flags string for building against this library
[ "Constructs", "the", "CMake", "invocation", "flags", "string", "for", "building", "against", "this", "library" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ThirdPartyLibraryDetails.py#L124-L136
18,292
tkrajina/git-plus
gitutils/__init__.py
is_changed
def is_changed(): """ Checks if current project has any noncommited changes. """ executed, changed_lines = execute_git('status --porcelain', output=False) merge_not_finished = mod_path.exists('.git/MERGE_HEAD') return changed_lines.strip() or merge_not_finished
python
def is_changed(): executed, changed_lines = execute_git('status --porcelain', output=False) merge_not_finished = mod_path.exists('.git/MERGE_HEAD') return changed_lines.strip() or merge_not_finished
[ "def", "is_changed", "(", ")", ":", "executed", ",", "changed_lines", "=", "execute_git", "(", "'status --porcelain'", ",", "output", "=", "False", ")", "merge_not_finished", "=", "mod_path", ".", "exists", "(", "'.git/MERGE_HEAD'", ")", "return", "changed_lines",...
Checks if current project has any noncommited changes.
[ "Checks", "if", "current", "project", "has", "any", "noncommited", "changes", "." ]
6adf9ae5c695feab5e8ed18f93777ac05dd4957c
https://github.com/tkrajina/git-plus/blob/6adf9ae5c695feab5e8ed18f93777ac05dd4957c/gitutils/__init__.py#L108-L112
18,293
edx/edx-rest-api-client
edx_rest_api_client/client.py
user_agent
def user_agent(): """ Return a User-Agent that identifies this client. Example: python-requests/2.9.1 edx-rest-api-client/1.7.2 ecommerce The last item in the list will be the application name, taken from the OS environment variable EDX_REST_API_CLIENT_NAME. If that environment variable is not set, it will default to the hostname. """ client_name = 'unknown_client_name' try: client_name = os.environ.get("EDX_REST_API_CLIENT_NAME") or socket.gethostbyname(socket.gethostname()) except: # pylint: disable=bare-except pass # using 'unknown_client_name' is good enough. no need to log. return "{} edx-rest-api-client/{} {}".format( requests.utils.default_user_agent(), # e.g. "python-requests/2.9.1" __version__, # version of this client client_name )
python
def user_agent(): client_name = 'unknown_client_name' try: client_name = os.environ.get("EDX_REST_API_CLIENT_NAME") or socket.gethostbyname(socket.gethostname()) except: # pylint: disable=bare-except pass # using 'unknown_client_name' is good enough. no need to log. return "{} edx-rest-api-client/{} {}".format( requests.utils.default_user_agent(), # e.g. "python-requests/2.9.1" __version__, # version of this client client_name )
[ "def", "user_agent", "(", ")", ":", "client_name", "=", "'unknown_client_name'", "try", ":", "client_name", "=", "os", ".", "environ", ".", "get", "(", "\"EDX_REST_API_CLIENT_NAME\"", ")", "or", "socket", ".", "gethostbyname", "(", "socket", ".", "gethostname", ...
Return a User-Agent that identifies this client. Example: python-requests/2.9.1 edx-rest-api-client/1.7.2 ecommerce The last item in the list will be the application name, taken from the OS environment variable EDX_REST_API_CLIENT_NAME. If that environment variable is not set, it will default to the hostname.
[ "Return", "a", "User", "-", "Agent", "that", "identifies", "this", "client", "." ]
7ed2a833691d2fdf3a4fbc9189ee5c4443bd892b
https://github.com/edx/edx-rest-api-client/blob/7ed2a833691d2fdf3a4fbc9189ee5c4443bd892b/edx_rest_api_client/client.py#L14-L34
18,294
edx/edx-rest-api-client
edx_rest_api_client/client.py
get_oauth_access_token
def get_oauth_access_token(url, client_id, client_secret, token_type='jwt', grant_type='client_credentials', refresh_token=None): """ Retrieves OAuth 2.0 access token using the given grant type. Args: url (str): Oauth2 access token endpoint client_id (str): client ID client_secret (str): client secret Kwargs: token_type (str): Type of token to return. Options include bearer and jwt. grant_type (str): One of 'client_credentials' or 'refresh_token' refresh_token (str): The previous access token (for grant_type=refresh_token) Returns: tuple: Tuple containing access token string and expiration datetime. """ now = datetime.datetime.utcnow() data = { 'grant_type': grant_type, 'client_id': client_id, 'client_secret': client_secret, 'token_type': token_type, } if refresh_token: data['refresh_token'] = refresh_token else: assert grant_type != 'refresh_token', "refresh_token parameter required" response = requests.post( url, data=data, headers={ 'User-Agent': USER_AGENT, }, ) data = response.json() try: access_token = data['access_token'] expires_in = data['expires_in'] except KeyError: raise requests.RequestException(response=response) expires_at = now + datetime.timedelta(seconds=expires_in) return access_token, expires_at
python
def get_oauth_access_token(url, client_id, client_secret, token_type='jwt', grant_type='client_credentials', refresh_token=None): now = datetime.datetime.utcnow() data = { 'grant_type': grant_type, 'client_id': client_id, 'client_secret': client_secret, 'token_type': token_type, } if refresh_token: data['refresh_token'] = refresh_token else: assert grant_type != 'refresh_token', "refresh_token parameter required" response = requests.post( url, data=data, headers={ 'User-Agent': USER_AGENT, }, ) data = response.json() try: access_token = data['access_token'] expires_in = data['expires_in'] except KeyError: raise requests.RequestException(response=response) expires_at = now + datetime.timedelta(seconds=expires_in) return access_token, expires_at
[ "def", "get_oauth_access_token", "(", "url", ",", "client_id", ",", "client_secret", ",", "token_type", "=", "'jwt'", ",", "grant_type", "=", "'client_credentials'", ",", "refresh_token", "=", "None", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "ut...
Retrieves OAuth 2.0 access token using the given grant type. Args: url (str): Oauth2 access token endpoint client_id (str): client ID client_secret (str): client secret Kwargs: token_type (str): Type of token to return. Options include bearer and jwt. grant_type (str): One of 'client_credentials' or 'refresh_token' refresh_token (str): The previous access token (for grant_type=refresh_token) Returns: tuple: Tuple containing access token string and expiration datetime.
[ "Retrieves", "OAuth", "2", ".", "0", "access", "token", "using", "the", "given", "grant", "type", "." ]
7ed2a833691d2fdf3a4fbc9189ee5c4443bd892b
https://github.com/edx/edx-rest-api-client/blob/7ed2a833691d2fdf3a4fbc9189ee5c4443bd892b/edx_rest_api_client/client.py#L40-L85
18,295
edx/edx-rest-api-client
edx_rest_api_client/client.py
OAuthAPIClient.request
def request(self, method, url, **kwargs): # pylint: disable=arguments-differ """ Overrides Session.request to ensure that the session is authenticated """ self._check_auth() return super(OAuthAPIClient, self).request(method, url, **kwargs)
python
def request(self, method, url, **kwargs): # pylint: disable=arguments-differ self._check_auth() return super(OAuthAPIClient, self).request(method, url, **kwargs)
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=arguments-differ", "self", ".", "_check_auth", "(", ")", "return", "super", "(", "OAuthAPIClient", ",", "self", ")", ".", "request", "(", "metho...
Overrides Session.request to ensure that the session is authenticated
[ "Overrides", "Session", ".", "request", "to", "ensure", "that", "the", "session", "is", "authenticated" ]
7ed2a833691d2fdf3a4fbc9189ee5c4443bd892b
https://github.com/edx/edx-rest-api-client/blob/7ed2a833691d2fdf3a4fbc9189ee5c4443bd892b/edx_rest_api_client/client.py#L121-L126
18,296
greenbone/ospd
ospd/ospd_ssh.py
OSPDaemonSimpleSSH.run_command
def run_command(self, scan_id, host, cmd): """ Run a single command via SSH and return the content of stdout or None in case of an Error. A scan error is issued in the latter case. For logging into 'host', the scan options 'port', 'username', 'password' and 'ssh_timeout' are used. """ ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) options = self.get_scan_options(scan_id) port = int(options['port']) timeout = int(options['ssh_timeout']) # For backward compatibility, consider the legacy mode to get # credentials as scan_option. # First and second modes should be removed in future releases. # On the third case it receives the credentials as a subelement of # the <target>. credentials = self.get_scan_credentials(scan_id, host) if ('username_password' in options and ':' in options['username_password']): username, password = options['username_password'].split(':', 1) elif 'username' in options and options['username']: username = options['username'] password = options['password'] elif credentials: cred_params = credentials.get('ssh') username = cred_params.get('username', '') password = cred_params.get('password', '') else: self.add_scan_error(scan_id, host=host, value='Erroneous username_password value') raise ValueError('Erroneous username_password value') try: ssh.connect(hostname=host, username=username, password=password, timeout=timeout, port=port) except (paramiko.ssh_exception.AuthenticationException, socket.error) as err: # Errors: No route to host, connection timeout, authentication # failure etc,. self.add_scan_error(scan_id, host=host, value=str(err)) return None _, stdout, _ = ssh.exec_command(cmd) result = stdout.readlines() ssh.close() return result
python
def run_command(self, scan_id, host, cmd): ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) options = self.get_scan_options(scan_id) port = int(options['port']) timeout = int(options['ssh_timeout']) # For backward compatibility, consider the legacy mode to get # credentials as scan_option. # First and second modes should be removed in future releases. # On the third case it receives the credentials as a subelement of # the <target>. credentials = self.get_scan_credentials(scan_id, host) if ('username_password' in options and ':' in options['username_password']): username, password = options['username_password'].split(':', 1) elif 'username' in options and options['username']: username = options['username'] password = options['password'] elif credentials: cred_params = credentials.get('ssh') username = cred_params.get('username', '') password = cred_params.get('password', '') else: self.add_scan_error(scan_id, host=host, value='Erroneous username_password value') raise ValueError('Erroneous username_password value') try: ssh.connect(hostname=host, username=username, password=password, timeout=timeout, port=port) except (paramiko.ssh_exception.AuthenticationException, socket.error) as err: # Errors: No route to host, connection timeout, authentication # failure etc,. self.add_scan_error(scan_id, host=host, value=str(err)) return None _, stdout, _ = ssh.exec_command(cmd) result = stdout.readlines() ssh.close() return result
[ "def", "run_command", "(", "self", ",", "scan_id", ",", "host", ",", "cmd", ")", ":", "ssh", "=", "paramiko", ".", "SSHClient", "(", ")", "ssh", ".", "set_missing_host_key_policy", "(", "paramiko", ".", "AutoAddPolicy", "(", ")", ")", "options", "=", "se...
Run a single command via SSH and return the content of stdout or None in case of an Error. A scan error is issued in the latter case. For logging into 'host', the scan options 'port', 'username', 'password' and 'ssh_timeout' are used.
[ "Run", "a", "single", "command", "via", "SSH", "and", "return", "the", "content", "of", "stdout", "or", "None", "in", "case", "of", "an", "Error", ".", "A", "scan", "error", "is", "issued", "in", "the", "latter", "case", "." ]
cef773166b15a19c17764721d3fe404fa0e107bf
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd_ssh.py#L94-L147
18,297
greenbone/ospd
ospd/xml.py
get_result_xml
def get_result_xml(result): """ Formats a scan result to XML format. Arguments: result (dict): Dictionary with a scan result. Return: Result as xml element object. """ result_xml = Element('result') for name, value in [('name', result['name']), ('type', ResultType.get_str(result['type'])), ('severity', result['severity']), ('host', result['host']), ('test_id', result['test_id']), ('port', result['port']), ('qod', result['qod'])]: result_xml.set(name, str(value)) result_xml.text = result['value'] return result_xml
python
def get_result_xml(result): result_xml = Element('result') for name, value in [('name', result['name']), ('type', ResultType.get_str(result['type'])), ('severity', result['severity']), ('host', result['host']), ('test_id', result['test_id']), ('port', result['port']), ('qod', result['qod'])]: result_xml.set(name, str(value)) result_xml.text = result['value'] return result_xml
[ "def", "get_result_xml", "(", "result", ")", ":", "result_xml", "=", "Element", "(", "'result'", ")", "for", "name", ",", "value", "in", "[", "(", "'name'", ",", "result", "[", "'name'", "]", ")", ",", "(", "'type'", ",", "ResultType", ".", "get_str", ...
Formats a scan result to XML format. Arguments: result (dict): Dictionary with a scan result. Return: Result as xml element object.
[ "Formats", "a", "scan", "result", "to", "XML", "format", "." ]
cef773166b15a19c17764721d3fe404fa0e107bf
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/xml.py#L25-L44
18,298
greenbone/ospd
ospd/xml.py
simple_response_str
def simple_response_str(command, status, status_text, content=""): """ Creates an OSP response XML string. Arguments: command (str): OSP Command to respond to. status (int): Status of the response. status_text (str): Status text of the response. content (str): Text part of the response XML element. Return: String of response in xml format. """ response = Element('%s_response' % command) for name, value in [('status', str(status)), ('status_text', status_text)]: response.set(name, str(value)) if isinstance(content, list): for elem in content: response.append(elem) elif isinstance(content, Element): response.append(content) else: response.text = content return tostring(response)
python
def simple_response_str(command, status, status_text, content=""): response = Element('%s_response' % command) for name, value in [('status', str(status)), ('status_text', status_text)]: response.set(name, str(value)) if isinstance(content, list): for elem in content: response.append(elem) elif isinstance(content, Element): response.append(content) else: response.text = content return tostring(response)
[ "def", "simple_response_str", "(", "command", ",", "status", ",", "status_text", ",", "content", "=", "\"\"", ")", ":", "response", "=", "Element", "(", "'%s_response'", "%", "command", ")", "for", "name", ",", "value", "in", "[", "(", "'status'", ",", "...
Creates an OSP response XML string. Arguments: command (str): OSP Command to respond to. status (int): Status of the response. status_text (str): Status text of the response. content (str): Text part of the response XML element. Return: String of response in xml format.
[ "Creates", "an", "OSP", "response", "XML", "string", "." ]
cef773166b15a19c17764721d3fe404fa0e107bf
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/xml.py#L47-L69
18,299
greenbone/ospd
ospd/ospd.py
close_client_stream
def close_client_stream(client_stream, unix_path): """ Closes provided client stream """ try: client_stream.shutdown(socket.SHUT_RDWR) if unix_path: logger.debug('%s: Connection closed', unix_path) else: peer = client_stream.getpeername() logger.debug('%s:%s: Connection closed', peer[0], peer[1]) except (socket.error, OSError) as exception: logger.debug('Connection closing error: %s', exception) client_stream.close()
python
def close_client_stream(client_stream, unix_path): try: client_stream.shutdown(socket.SHUT_RDWR) if unix_path: logger.debug('%s: Connection closed', unix_path) else: peer = client_stream.getpeername() logger.debug('%s:%s: Connection closed', peer[0], peer[1]) except (socket.error, OSError) as exception: logger.debug('Connection closing error: %s', exception) client_stream.close()
[ "def", "close_client_stream", "(", "client_stream", ",", "unix_path", ")", ":", "try", ":", "client_stream", ".", "shutdown", "(", "socket", ".", "SHUT_RDWR", ")", "if", "unix_path", ":", "logger", ".", "debug", "(", "'%s: Connection closed'", ",", "unix_path", ...
Closes provided client stream
[ "Closes", "provided", "client", "stream" ]
cef773166b15a19c17764721d3fe404fa0e107bf
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L169-L180