Ejemplo n.º 1
0
 def list_craft_assets(self, filepath):
     ''' Reads the craft file and return all cfg folders '''
     craft_assets = set()
     with open(filepath, 'r') as craft_file:
         craft_data = craft_file.read()
         craftnodes = ConfigNode.load(craft_data)
         # FIXME: is part always the first value?
         assets_set = self.get_craft_unique_assets(craftnodes)
         for asset in assets_set:
             if asset not in self.parts:
                 print("Warning: part '{}' not found".format(asset))
             else:
                 if self.uses_qt:
                     from PyQt4 import QtCore
                     self.emitter.emit(QtCore.SIGNAL('building(QString, int, int)'), "Building", list(assets_set).index(asset), len(assets_set))
                 print('Getting files for {}'.format(asset))
                 craft_assets.update(self.get_asset_files(self.parts[asset]))
     return craft_assets
Ejemplo n.º 2
0
def main():
    wheel_mu = sys.argv[1]
    mu = Mu()
    if not mu.read(wheel_mu):
        print("could not read: " + fname)
        raise
    find_wheels(mu.obj)
    if len(sys.argv) > 2:
        text = open(sys.argv[2], "rt").read()
        node = ConfigNode.load(text)
        wheel = node.GetNode('Wheel')
        if not wheel:
            print("could not find Wheel")
            sys.exit(1)
        adjust_wheel(wheel)
        mu.write("wheelout.mu")
    else:
        for w in wheel_colliders.keys():
            node = wheel_cfg(w, wheel_colliders[w])
            print("Wheel "+ node.ToString())
Ejemplo n.º 3
0
 def list_craft_assets(self, filepath):
     ''' Reads the craft file and return all cfg folders '''
     craft_assets = set()
     with open(filepath, 'r') as craft_file:
         craft_data = craft_file.read()
         craftnodes = ConfigNode.load(craft_data)
         # FIXME: is part always the first value?
         assets_set = self.get_craft_unique_assets(craftnodes)
         for asset in assets_set:
             if asset not in self.parts:
                 print("Warning: part '{}' not found".format(asset))
             else:
                 if self.uses_qt:
                     from PyQt4 import QtCore
                     self.emitter.emit(
                         QtCore.SIGNAL('building(QString, int, int)'),
                         "Building",
                         list(assets_set).index(asset), len(assets_set))
                 print('Getting files for {}'.format(asset))
                 craft_assets.update(self.get_asset_files(
                     self.parts[asset]))
     return craft_assets
Ejemplo n.º 4
0
from cfgnode import ConfigNode


def get_cfg_values(one_node, val_type):
    assert isinstance(one_node, ConfigNode)
    return [i[1] for i in one_node.values if i[0] == val_type]


part_node_dict = dict()
child_parent_map = dict()
parent_children_map = dict()
all_partnames = list()
parentage_crosses_stage = list()

loaded_config_nodes = ConfigNode.load(
    open(args.ship_file, encoding="utf-8").read())
print("Load successful")
theparts = [p[1] for p in loaded_config_nodes.nodes if p[0] == "PART"]

for partNode in theparts:
    partpart = [i[1] for i in partNode.values if i[0] == "part"][0]
    partNode_childlinks = [i[1] for i in partNode.values if i[0] == "link"]
    for one_child in partNode_childlinks:
        child_parent_map[one_child] = partpart
    parent_children_map[partpart] = partNode_childlinks
    all_partnames.append(partpart)
    part_node_dict[partpart] = partNode

for child, parent in child_parent_map.items():
    child_stage = get_cfg_values(part_node_dict[child], "istg")[0]
    parent_stage = get_cfg_values(part_node_dict[parent], "istg")[0]
Ejemplo n.º 5
0
        other_part = part_map[port.GetValue('dockUId')]
        other_port = find_module(other_part, "ModuleDockingNode")
        if other_port.GetValue('dockUId') != p.GetValue('uid'):
            continue
        if parts.index(other_part) != int(p.GetValue('parent')):
            continue
        events = port.GetNode('EVENTS')
        undock = events.GetNode('Undock')
        print(p.GetValue('uid'), port.GetValue('state'),
              port.GetValue('dockUId'))
        count += 1
    return count


for arg in sys.argv[1:]:
    text = open(arg, "rt").read()
    node = ConfigNode.load(text)
    game = node.GetNode('GAME')
    if not game:
        print("could not find GAME")
        sys.exit(1)
    flightstate = game.GetNode("FLIGHTSTATE")
    if not flightstate:
        print("could not find FLIGHTSTATE")
        sys.exit(1)
    vessels = flightstate.GetNodes("VESSEL")
    for v in vessels:
        if check_ports(v):
            print(v.GetValue("name"), v.GetValue("type"))
    sys.exit(0)
Ejemplo n.º 6
0
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

# <pep8 compliant>

from cfgnode import ConfigNode
import sys

src = sys.argv[1]
dst = sys.argv[2]
out = sys.argv[3]

src_text = open(src, "rt").read()
dst_text = open(dst, "rt").read()
src_node = ConfigNode.load(src_text)
src_game = src_node.GetNode('GAME')
dst_node = ConfigNode.load(dst_text)
dst_game = dst_node.GetNode('GAME')
if not src_game:
    print("could not find source GAME")
    sys.exit(1)
if not dst_game:
    print("could not find destination GAME")
    sys.exit(1)

src_flightstate = src_game.GetNode("FLIGHTSTATE")
if not src_flightstate:
    print("could not find source FLIGHTSTATE")
    sys.exit(1)
dst_flightstate = dst_game.GetNode("FLIGHTSTATE")
Ejemplo n.º 7
0
        if 'Docked' in port.GetValue('state'):
            continue
        other_part = part_map[port.GetValue('dockUId')]
        other_port = find_module(other_part, "ModuleDockingNode")
        if other_port.GetValue('dockUId') != p.GetValue('uid'):
            continue
        if parts.index(other_part) != int(p.GetValue('parent')):
            continue
        events = port.GetNode('EVENTS')
        undock = events.GetNode('Undock')
        print(p.GetValue('uid'), port.GetValue('state'), port.GetValue('dockUId'))
        count+=1
    return count

for arg in sys.argv[1:]:
    text = open(arg, "rt").read()
    node = ConfigNode.load(text)
    game = node.GetNode('GAME')
    if not game:
        print("could not find GAME")
        sys.exit(1)
    flightstate = game.GetNode("FLIGHTSTATE")
    if not flightstate:
        print("could not find FLIGHTSTATE")
        sys.exit(1)
    vessels = flightstate.GetNodes("VESSEL")
    for v in vessels:
        if check_ports(v):
            print(v.GetValue("name"), v.GetValue("type"))
    sys.exit(0)