Пример #1
0
def getaddrinfo(host,
                port,
                family=AF_INET,
                socktype=SOCK_STREAM,
                proto=IPPROTO_IP,
                flags=None):
    entry = _safe_gethostbyname(host)
    family = Enum.ToObject(AddressFamily, family)
    socktype = Enum.ToObject(ClrSocketType, socktype)
    proto = Enum.ToObject(ProtocolType, proto)
    if family == AF_UNSPEC:
        family = AF_INET
    return [(family, socktype, proto, '', (str(ip), port))
            for ip in entry.AddressList]
Пример #2
0
def test_face(chara, face):
    import Manager.ADV
    from System import Enum
    from Manager.ADV import FacialExpressionPattern as Face
    if not isinstance(face, Face):
        face = Enum.Parse(Face, face, True)
    Manager.ADV.Instance.SetFacialExpression(chara, face)
Пример #3
0
 def callable(*args):
     from Microsoft.Scripting import SourceSpan, TokenCategory, TokenInfo, TokenTriggers
     TokenTriggersNone = getattr(TokenTriggers, "None")
     TokenCategoryNone = getattr(TokenCategory, "None")
     from System import Enum
     triggers = args[2] if len(args)>2  else TokenTriggersNone
     return TokenInfo(SourceSpan(args[0], args[1]),
             Enum.Parse(TokenCategoryNone.GetType(), name), triggers)
Пример #4
0
def mike1d_quantities():
    """
    Returns all predefined Mike1D quantities.
    Useful for knowing what quantity string to query.
    """
    return [
        quantity
        for quantity in Enum.GetNames(clr.GetClrType(PredefinedQuantity))
    ]
Пример #5
0
 def _parse(self, reader):
     settings = XmlReaderSettings(ProhibitDtd=False)
     reader = XmlReader.Create(reader, settings)
     self._reader = reader
     while reader.Read():
         nodetype = reader.NodeType
         typename = Enum.GetName(XmlNodeType, nodetype)
         handler = getattr(self, '_handle_' + typename, None)
         if handler is not None:
             handler()
Пример #6
0
def _getlist(it):
    lst = []
    while it.MoveNext():
        from System import Enum
        code = Enum.ToObject(acrx.LispDataType, it.Current.TypeCode)
        if code == acrx.LispDataType.ListEnd:
            return lst
        elif code == acrx.LispDataType.DottedPair:
            return tuple(lst)
        elif code == acrx.LispDataType.ListBegin:
            lst.append(_getlist(it))
        elif code == acrx.LispDataType.T_atom:
            lst.append(True)
        elif code == acrx.LispDataType.Nil:
            lst.append(False)
        else:
            lst.append(it.Current.Value)
    return lst
Пример #7
0
    def intercepted_key(self, e):
        log.info('intercepted key event')
        # FIXME: Split key intercept handling out of this program
        # FIXME: abstract key processing to a helper module; replace key
        # processing here and in preview key down

        # should always be a modifier
        modifier, keyname = e.Key.split('-', 1)

        # http://www.codeproject.com/Articles/6768/Tips-about-NET-Enums
        key = Enum.Parse(Keys, keyname)

        if key in keys:
            key = keys[key]

        key = str(key)

        if key in set(string.uppercase):
            key = key.lower()

        key = '-'.join((modifier, key))

        log.info('intercepted key: ' + key)
        zmq.send_command(key)
Пример #8
0
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 11 12:54:57 2017

@author: Steven
"""

# Python .NET interface
from dotnet.seamless import add_assemblies, load_assembly#, build_assembly

# load PLEXOS assemblies
plexos_path = 'C:/Program Files (x86)/Energy Exemplar/PLEXOS 7.5/'
add_assemblies(plexos_path)
load_assembly('EEUTILITY')

# .NET related imports
from EEUTILITY.Enums import *
from System import Enum

fout = open('EEUTILITY_Enums.txt', 'w')

for t in type(ClassEnum).Assembly.GetTypes():
    if t.IsEnum:
        fout.write('{}\n'.format(t.Name))
        for en in t.GetEnumNames():
            fout.write('\t{} = {}\n'.format(en, int(Enum.Parse(t, en))))
        fout.write('\n')

fout.close()
Пример #9
0
from MF_GetFilterRules import *

from MF_CustomForms import *

from MF_MultiMapParameters import *

from MF_ExcelOutput import *

filters = FilteredElementCollector(doc).OfClass(ParameterFilterElement)

allViews = FilteredElementCollector(doc).OfClass(View).ToElements()

viewTemplates = []

allBuiltInCategories = Enum.GetValues(clr.GetClrType(BuiltInCategory))

allCategories = [i for i in doc.Settings.Categories]

modelCategories = []

modelCategoryNames = []

time = strftime("%Y-%m-%d %H:%M:%S", localtime())

projectInfo = [["Project File: ", doc.Title], ["Path", doc.PathName],
               ["Export Date:", time]]

for c in allCategories:

    #c = doc.GetCategory( bic)
 def _window_state_to_str(state):
     return Enum.GetName(DisplayState, state)
Пример #11
0

##############################
def group(seq, sep):
    g = []
    for el in seq:
        if el == sep:
            yield g
            g = []
        g.append(el)
    yield g


time = strftime("%Y-%m-%d %H:%M:%S", localtime())

bics = Enum.GetValues(clr.GetClrType(BuiltInCategory))
bicats = []
for bic in bics:

    try:
        if doc.Settings.Categories.get_Item(bic):
            c = doc.Settings.Categories.get_Item(bic)
            bicats.append(c)
            #catIDs.append(c.Id)

            realCat = Category.GetCategory(doc, bic)
            bicats.append("realCat" + str(realCat))

    except Exception as e:
        bicats.append(str(e))
        pass
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import BuiltInParameter
from System import Enum

key = 'FAMILY_HOSTING_BEHAVIOR'

names = Enum.GetNames(BuiltInParameter)
values = Enum.GetValues(BuiltInParameter)

bip_dict = dict(zip(names, values))
# Returns a BuiltInParameter given its name (key)
bip = bip_dict[key]

# For above solution 
# See: https://forum.dynamobim.com/t/setting-built-in-parameter-by-using-a-variable-value/49466


# Get the Plumbing Fixtures from the model.
pfs = (FilteredElementCollector(doc)
  .OfCategory(BuiltInCategory.OST_PlumbingFixtures)
  .WhereElementIsNotElementType()
  .ToList()
)


# Loop through them and check the BuiltInParameter for Hosting Behaviour
# Looking for Floor Hosted families only
i = 0
for pf in pfs:
  i += 1
Пример #13
0
def pull_data(sol_cxn, time_res, args, arg_opt, default_csv):
    from EEUTILITY.Enums import SimulationPhaseEnum, CollectionEnum, PeriodEnum, ClassEnum

    # is this time_res active? If not quit
    if not is_switch(args, arg_opt): return

    # date_from and date_to
    date_from = switch_data_to_date(args, '-f')
    date_to = switch_data_to_date(args, '-t')

    start_time = time.time() # start timer

    # get the csv_file name
    csv_file = switch_data(args, arg_opt)
    if csv_file is None:
        csv_file = re.sub('\.zip$', '', args[1]) + default_csv

    # remove the csv_file if it already exists
    if os.path.exists(csv_file): os.remove(csv_file)

    # loop through all relevant collections and phases
    config_json = switch_data(args, '-c')
    if not config_json is None and os.path.exists(config_json):
        cfg_json_obj = json.load(open(config_json))
        for query in cfg_json_obj['queries']:
            try:
                phase = Enum.Parse(SimulationPhaseEnum, query['phase'])
                coll = sol_cxn.CollectionName2Id(query['parentclass'], query['childclass'], query['collection'])
            except:
                print("Phase:", query['phase'], "Collection:", query['collection'], "Parent Class:", query['parentclass'], "Child Class:",  query['childclass'])
                print(" --> This combination doesn't identify queryable information")
                continue # If the phase or collection are missing or incorrect just skip

            if 'properties' in query:
                # the data in properties field may be a list of property names; we'll pull each individually
                if type(query['properties']) is list:
                    for prop in query['properties']:
                        try:
                            prop_id = str(sol_cxn.PropertyName2EnumId(query['parentclass'], query['childclass'], query['collection'], prop))
                            query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v'), property_list=prop_id)
                        except:
                            pass
                
                # the data in properties field may be a single property name; we'll just pull it
                elif type(query['properties']) is str:
                    try:
                        prop_id = str(sol_cxn.PropertyName2EnumId(query['parentclass'], query['childclass'], query['collection'], query['properties']))
                        query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v'), property_list=prop_id)
                    except:
                        pass
                
                # the data in properties field may be poorly formatted
                else:
                    print(query['properties'],'is not valid property information')

            # properties field may be missing; just pull all properties
            else:
                query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v'))
    else:
        for phase in Enum.GetValues(clr.GetClrType(SimulationPhaseEnum)):
            for coll in Enum.GetValues(clr.GetClrType(CollectionEnum)):
                query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v'))

    print('Completed',clr.GetClrType(PeriodEnum).GetEnumName(time_res),'in',time.time() - start_time,'sec')
Пример #14
0
class ConsoleColorMgr(object):
    def __init__(self, foreground=None, background=None):
        self.foreground = foreground
        self.background = background

    def __enter__(self):
        self._tempFG = _Console.ForegroundColor
        self._tempBG = _Console.BackgroundColor

        if self.foreground: _Console.ForegroundColor = self.foreground
        if self.background: _Console.BackgroundColor = self.background

    def __exit__(self, t, v, tr):
        _Console.ForegroundColor = self._tempFG
        _Console.BackgroundColor = self._tempBG


import sys

_curmodule = sys.modules[__name__]

from System import ConsoleColor, Enum
for n in Enum.GetNames(ConsoleColor):
    setattr(_curmodule, n, ConsoleColorMgr(Enum.Parse(ConsoleColor, n)))

del ConsoleColor
del Enum
del sys
del _curmodule
del n
Пример #15
0
    roi.Name = ofRoi.Name
    if ofRoi.DerivedRoiExpression is not None:
        roi.IsDerived = True
        roi.DependentRois = r.GetDependentRois()
    else:
        roi.IsDerived = False
        roi.DependentRois = List[str]()

    roi.HasGeometry = r.HasContours()
    roi.CanDeleteGeometry = False
    roi.CanUnderive = False
    roi.CanUpdate = False
    roi.CanDeleteGeometry = False
    roi.CaseName = case.CaseName
    roi.ExaminationName = examinations.SelectedExamination
    roi.RoiType = Enum.Parse(clr.GetClrType(RoiType), ofRoi.Type)
    roi.Color = Media.Color.FromRgb(ofRoi.Color.R, ofRoi.Color.G,
                                    ofRoi.Color.B)

    rois.Add(roi)

from RoiManager.ViewModels import RoiSelectionViewModel
roiSelectionViewModel = RoiSelectionViewModel(rois, roiNameMappingTable)

from RoiManager.Views import MainWindow
mainWindow = MainWindow(roiSelectionViewModel)
mainWindow.ShowDialog()

print "RoiSelection CanExecute: ", roiSelectionViewModel.CanExecute

if not roiSelectionViewModel.CanExecute:
Пример #16
0
def get_type_name(type):
    typeName = Enum.GetName(SensorType, type)
    return typeName
Пример #17
0
comp.HDDEnabled = False
comp.Open()

for hw in comp.Hardware:
    print(hw.Identifier, hardware)
    if str(hw.Identifier) in hardware:
        __hw.append(hw)

        hw.Update()
        for sensor in hw.Sensors:
            if str(sensor.Identifier) in sensors:
                __sensors.append(sensor)

while True:

    try:
        for hw in __hw:
            hw.Update()
            for sensor in __sensors:

                typeName = Enum.GetName(SensorType, sensor.SensorType)

                print("name: %s - sensor: %s - type: %s - value: %s" %
                      (sensor.Name, sensor.Identifier, typeName, sensor.Value))

        print('---')
        time.sleep(1)
    except KeyboardInterrupt:
        break

comp.Close()
Пример #18
0
 def enum_generator():
     for enum_member in Enum.GetValues(Enum):
         yield enum_member  # type: Enum
Пример #19
0
def socket(family=AF_INET, type=SOCK_STREAM, proto=IPPROTO_IP):
    family = Enum.ToObject(AddressFamily, family)
    type = Enum.ToObject(ClrSocketType, type)
    proto = Enum.ToObject(ProtocolType, proto)
    socket = Socket(family, type, proto)
    return PythonSocket(socket)
Пример #20
0
def MF_GetFilterRules(f):
    types = []
    pfRuleList = []
    categories = ''
    for c in f.GetCategories():
        categories += Category.GetCategory(doc, c).Name + "  ,  "

    for rule in f.GetRules():

        try:
            comparator = ""
            ruleValue = ""
            ruleInfo = ""

            if rule.GetType() == FilterDoubleRule:
                ruleValue = "filterdoublerule"

                fdr = rule

                if (fdr.GetEvaluator().GetType() == FilterNumericLess):
                    comparator = "<"
                elif (fdr.GetEvaluator().GetType() == FilterNumericGreater):
                    comparator = ">"

                ruleValue = fdr.RuleValue.ToString()

                ruleName = ruleValue

            if rule.GetType() == FilterStringRule:
                ruleValue = "filterstringrule"

                fsr = rule

                if (fsr.GetEvaluator().GetType() == FilterStringBeginsWith):
                    comparator = "starts with"
                elif (fsr.GetEvaluator().GetType() == FilterStringEndsWith):
                    comparator = "ends with"
                elif (fsr.GetEvaluator().GetType() == FilterStringEquals):
                    comparator = "equals"
                elif (fsr.GetEvaluator().GetType() == FilterStringContains):
                    comparator = "contains"

                ruleValue = fsr.RuleString

                ruleName = ruleValue

            if rule.GetType() == FilterInverseRule:
                # handle 'string does not contain '

                fInvr = rule.GetInnerRule()

                if (fsr.GetEvaluator().GetType() == FilterStringBeginsWith):
                    comparator = "does not start with"
                elif (fsr.GetEvaluator().GetType() == FilterStringEndsWith):
                    comparator = "does not end with"
                elif (fsr.GetEvaluator().GetType() == FilterStringEquals):
                    comparator = "does not equal"
                elif (fsr.GetEvaluator().GetType() == FilterStringContains):
                    comparator = "does not contain"

                ruleValue = fInvr.RuleString

                ruleName = ruleValue

            if rule.GetType() == FilterIntegerRule:

                #comparator = "equals"
                ruleValue = "filterintegerrule"

                fir = rule

                if (fir.GetEvaluator().GetType() == FilterNumericEquals):
                    comparator = "="
                elif (fir.GetEvaluator().GetType() == FilterNumericGreater):
                    comparator = ">"
                elif (fir.GetEvaluator().GetType() == FilterNumericLess):
                    comparator = "<"

                ruleValue = fir.RuleValue

            if rule.GetType() == FilterElementIdRule:

                comparator = "equals"
                feidr = rule

                ruleValue = doc.GetElement(feidr.RuleValue)

                ruleName = ruleValue.Abbreviation

                t = ruleValue.GetType()
                #ruleName = doc.GetElement(ruleValue.Id).Name
                types.append(t)

            paramName = ""
            bipName = " - "
            if (ParameterFilterElement.GetRuleParameter(rule).IntegerValue <
                    0):

                bpid = f.GetRuleParameter(rule).IntegerValue

                #bp = System.Enum.Parse(clr.GetClrType(ParameterType), str(bpid) )

                #paramName = LabelUtils.GetLabelFor.Overloads[BuiltInParameter](bpid)
                #paramName = doc.get_Parameter(ElementId(bpid)).ToString()
                paramName = Enum.Parse(clr.GetClrType(BuiltInParameter),
                                       str(bpid))
                param = Enum.Parse(clr.GetClrType(BuiltInParameter), str(bpid))
                bipName = param.ToString()

                #YESSS
                paramName = LabelUtils.GetLabelFor.Overloads[BuiltInParameter](
                    param)

            else:
                paramName = doc.GetElement(
                    ParameterFilterElement.GetRuleParameter(rule)).Name
            #paramName = doc.GetElement(ParameterFilterElement.GetRuleParameter(rule)).Name

            #ruleData += "'" + paramName + "' " + comparator + " " + "'" + ruleValue.ToString() + "'" + Environment.NewLine;
            #ruleInfo += "'" + str(paramName) + "' " + comparator + " " + "'" + ruleValue.ToString() + "---"
            try:
                ruleInfo += "" + str(
                    paramName
                ) + " - " + bipName + " -  " + comparator + " - " + ruleValue.ToString(
                ) + " - " + ruleName + " - " + rule.GetType().ToString(
                ) + "   ---   "

                pfRuleList += [(str(paramName)), (bipName), (comparator),
                               (ruleValue.ToString()), (ruleName),
                               (rule.GetType().ToString()), (" --- ")]

            except:
                ruleInfo += "" + str(
                    paramName
                ) + " - " + bipName + " - " + comparator + " -  " + ruleValue.ToString(
                ) + " -  " + ruleName.ToString() + " - " + rule.GetType(
                ).ToString() + "   ---   "

                pfRuleList += [(str(paramName)), (bipName), (comparator),
                               (ruleValue.ToString()), (ruleName.ToString()),
                               (rule.GetType().ToString()), (" --- ")]

        #ruleList.append([str(paramName), comparator, ruleName])
        #ruleInfo = ( (str(paramName) , comparator , ruleValue.ToString() ) )
        #filterRuleList.append(pfRuleList)

        #ruleValues.append(ruleValue)

        except Exception as e:
            print str(e)

        #sublist.extend(pfRuleList)

        return [categories, pfRuleList]