Query on study properties. See documentation for _OTIWrapper class.
513293
def find_studies(self, query_dict=None, exact=False, verbose=False, **kwargs):
        """"""
        if self.use_v1:
            uri = '{p}/singlePropertySearchForStudies'.format(p=self.query_prefix)
        else:
            uri = '{p}/find_studies'.format(p=self.query_prefix)
        return self._do_query(uri,
                              query_dict=query_dict,
                              exact=exact,
                              verbose=verbose,
                              valid_keys=self.study_search_term_set,
                              kwargs=kwargs)
621156
public List<Pedigree> getPedigree(String studyId) {
        Member dest;
        Map<String, Pedigree> pedigreeMap = new HashMap<>();
        Map<String, Member> individualMap = new HashMap<>();

        VariantStudyMetadata variantStudyMetadata = getVariantStudyMetadata(studyId);
        if (variantStudyMetadata != null) {

            // first loop
            for (org.opencb.biodata.models.metadata.Individual src: variantStudyMetadata.getIndividuals()) {

                String pedigreeName = src.getFamily();
                if (!pedigreeMap.containsKey(pedigreeName)) {
                    pedigreeMap.put(pedigreeName, new Pedigree(pedigreeName, new ArrayList<>(), new HashMap<>()));
                }

                // main fields
                dest = new Member(src.getId(), Member.Sex.getEnum(src.getSex()),
                        Member.AffectionStatus.getEnum(src.getPhenotype()));

                // attributes
                if (src.getSamples() != null && src.getSamples().size() > 0) {
                    Map<String, String> annotation = src.getSamples().get(0).getAnnotations();
                    if (annotation != null) {
                        Map<String, Object> variables = new HashMap<>();
                        for (String key: annotation.keySet()) {
                            if (key.equals(INDIVIDUAL_ID) || key.equals(INDIVIDUAL_FAMILY)
                                    || key.equals(INDIVIDUAL_FATHER) || key.equals(INDIVIDUAL_MOTHER)
                                    || key.equals(INDIVIDUAL_SEX) || key.equals(INDIVIDUAL_PHENOTYPE)) {
                                continue;
                            }
                            String fields[] = key.split(":");
                            if (fields.length > 1) {
                                switch (fields[1].toLowerCase()) {
                                    case "i":
                                        variables.put(fields[0], Integer.parseInt(annotation.get(key)));
                                        break;
                                    case "d":
                                        variables.put(fields[0], Double.parseDouble(annotation.get(key)));
                                        break;
                                    case "b":
                                        variables.put(fields[0], Boolean.parseBoolean(annotation.get(key)));
                                        break;
                                    default:
                                        variables.put(fields[0], annotation.get(key));
                                }
                            } else {
                                variables.put(fields[0], annotation.get(key));
                            }
                        }
                        dest.setAttributes(variables);
                    }
                }
                pedigreeMap.get(pedigreeName).getMembers().add(dest);
                individualMap.put(pedigreeName + "_" + dest.getName(), dest);
            }

            // second loop: setting fathers, mothers, partners and children
            for (org.opencb.biodata.models.metadata.Individual src: variantStudyMetadata.getIndividuals()) {
                // update father, mother and child
                Member father = individualMap.get(src.getFamily() + "_" + src.getFather());
                Member mother = individualMap.get(src.getFamily() + "_" + src.getMother());
                Member child = individualMap.get(src.getFamily() + "_" + src.getId());

                // setting father and children
                if (father != null) {
                    child.setFather(father);
                    if (father.getMultiples() == null) {
                        Multiples multiples = new Multiples().setType("children").setSiblings(new ArrayList<>());
                        father.setMultiples(multiples);
                    }
                    father.getMultiples().getSiblings().add(child.getName());
                }

                // setting mother and children
                if (mother != null) {
                    child.setMother(mother);
                    if (mother.getMultiples() == null) {
                        Multiples multiples = new Multiples().setType("children").setSiblings(new ArrayList<>());
                        mother.setMultiples(multiples);
                    }
                    mother.getMultiples().getSiblings().add(child.getName());
                }
            }

        }

        // create the list of Pedigree objects from the map
        return new ArrayList<>(pedigreeMap.values());
    }
60794
def get(self, **kwargs):
        
        db_url = ':'.join([options.url_registry_db, str(options.db_port)])
        db = couch.AsyncCouch(db_name=self.db_name, couch_url=db_url)

        result = yield db.view(
            design_doc_name=self.name,
            view_name=self.name,
            **kwargs)

        raise Return(result)
145583
def with_wrapper(self, wrapper=None, name=None):
        
        name = name or '{}_custom_wrapper'.format(self.name)
        return self.__class__(self.data, name=name, wrapper=wrapper)
1055664
def get_properties(cls_def):
    
    # pdb.set_trace()
    prop_list = {prop: value for prop, value in cls_def.items() \
                 if 'rdf_Property' in value.get('rdf_type', "") or \
                 value.get('rdfs_domain')}

    return prop_list
939826
def __pull_combined_properties(self):
        

        query_params = {
            "titles": self.title,
            "prop": "extracts|redirects|links|coordinates|categories|extlinks",
            "continue": dict(),
            # summary
            "explaintext": "",
            "exintro": "",  # full first section for the summary!
            # redirects
            "rdprop": "title",
            "rdlimit": "max",
            # links
            "plnamespace": 0,
            "pllimit": "max",
            # coordinates
            "colimit": "max",
            # categories
            "cllimit": "max",
            "clshow": "!hidden",
            # references
            "ellimit": "max",
        }

        last_cont = dict()
        results = dict()
        idx = 0
        while True:
            params = query_params.copy()
            params.update(last_cont)

            request = self.mediawiki.wiki_request(params)
            idx += 1

            # print(idx)
            # quick exit
            if "query" not in request:
                # print(request)
                break

            keys = [
                "extracts",
                "redirects",
                "links",
                "coordinates",
                "categories",
                "extlinks",
            ]
            new_cont = request.get("continue")
            request = request["query"]["pages"][self.pageid]
            if not results:
                results = request
            else:
                for key in keys:
                    if key in request and request.get(key) is not None:
                        val = request.get(key)
                        tmp = results.get(key)
                        if isinstance(tmp, (list, tuple)):
                            results[key] = results.get(key, list) + val
            if new_cont is None or new_cont == last_cont:
                break

            last_cont = new_cont

        # redirects
        tmp = [link["title"] for link in results.get("redirects", list())]
        self._redirects = sorted(tmp)

        # summary
        self._summary = results["extract"]

        # links
        tmp = [link["title"] for link in results.get("links", list())]
        self._links = sorted(tmp)

        # categories
        def _get_cat(val):
            """ parse the category correctly """
            tmp = val["title"]
            if tmp.startswith(self.mediawiki.category_prefix):
                return tmp[len(self.mediawiki.category_prefix) + 1 :]
            return tmp

        tmp = [_get_cat(link) for link in results.get("categories", list())]
        self._categories = sorted(tmp)

        # coordinates
        if "coordinates" in results:
            self._coordinates = (
                Decimal(results["coordinates"][0]["lat"]),
                Decimal(results["coordinates"][0]["lon"]),
            )

        # references
        tmp = [link["*"] for link in results.get("extlinks", list())]
        self._references = sorted(tmp)
667092
def get_data(ctx, study, environment, subject):
    
    cfg = GetDataConfigurableDataset(GET_DATA_DATASET,
                                     study,
                                     environment,
                                     subject,
                                     params=dict(IncludeIDs=0,
                                                 IncludeValues=0))
    # path = "datasets/{}?StudyOID={}&SubjectKey={}" \
    #        "&IncludeIDs=0&IncludeValues=0".format(GET_DATA_DATASET, studyoid, subject)
    # url = make_url(ctx.obj['RWS'].base_url, path)

    if ctx.obj['VERBOSE']:
        click.echo('Getting data list')
    # Get the client instance
    client = ctx.obj['RWS']  #: type: RWSConnection
    # Client rolls in the base_url
    resp = client.send_request(cfg)
    # resp = requests.get(url, auth=HTTPBasicAuth(ctx.obj['USERNAME'], ctx.obj['PASSWORD']))

    if client.last_result.status_code != 200:
        click.echo(client.last_result.text)

    return xml_pretty_print(resp)
604197
def process_docstring(app, what, name, obj, options, lines):
    
    aliases = getattr(app, "_sigaliases", None)
    if aliases is None:
        if what == "module":
            aliases = get_aliases(inspect.getsource(obj).splitlines())
            app._sigaliases = aliases

    sig_marker = ":" + SIG_FIELD + ":"
    is_class = what in ("class", "exception")

    signature = extract_signature("\n".join(lines))
    if signature is None:
        if not is_class:
            return

        init_method = getattr(obj, "__init__")
        init_doc = init_method.__doc__
        init_lines = init_doc.splitlines()[1:]
        if len(init_lines) > 1:
            init_doc = textwrap.dedent("\n".join(init_lines[1:]))
            init_lines = init_doc.splitlines()
        if sig_marker not in init_doc:
            return

        sig_started = False
        for line in init_lines:
            if line.lstrip().startswith(sig_marker):
                sig_started = True
            if sig_started:
                lines.append(line)
        signature = extract_signature("\n".join(lines))

    if is_class:
        obj = init_method

    param_types, rtype, _ = parse_signature(signature)
    param_names = [p for p in inspect.signature(obj).parameters]

    if is_class and (param_names[0] == "self"):
        del param_names[0]

    # if something goes wrong, don't insert parameter types
    if len(param_names) == len(param_types):
        for name, type_ in zip(param_names, param_types):
            find = ":param %(name)s:" % {"name": name}
            alias = aliases.get(type_)
            if alias is not None:
                type_ = "*%(type)s* :sup:`%(alias)s`" % {"type": type_, "alias": alias}
            for i, line in enumerate(lines):
                if line.startswith(find):
                    lines.insert(i, ":type %(name)s: %(type)s" % {"name": name, "type": type_})
                    break

    if not is_class:
        for i, line in enumerate(lines):
            if line.startswith((":return:", ":returns:")):
                lines.insert(i, ":rtype: " + rtype)
                break

    # remove the signature field
    sig_start = 0
    while sig_start < len(lines):
        if lines[sig_start].startswith(sig_marker):
            break
        sig_start += 1
    sig_end = sig_start + 1
    while sig_end < len(lines):
        if (not lines[sig_end]) or (lines[sig_end][0] != " "):
            break
        sig_end += 1
    for i in reversed(range(sig_start, sig_end)):
        del lines[i]
529274
async function getStudySetup() {
  // shallow copy
  const studySetup = Object.assign({}, baseStudySetup);

  studySetup.allowEnroll = await cachingFirstRunShouldAllowEnroll(studySetup);

  const testingOverrides = await browser.study.getTestingOverrides();
  studySetup.testing = {
    variationName: testingOverrides.variationName,
    firstRunTimestamp: testingOverrides.firstRunTimestamp,
    expired: testingOverrides.expired,
  };

  return studySetup;
}
265053
def properties_operator(cls, name):
    """"""

    def wrapper(self, *args, **kwargs):
        """Perform operation and cast to container class"""
        output = getattr(super(cls, self), name)(*args, **kwargs)
        return cls(output)

    wrapped = getattr(cls, name)
    wrapper.__name__ = wrapped.__name__
    wrapper.__doc__ = wrapped.__doc__
    return wrapper
161368
def _tp__get_typed_properties(self):
        
        try:
            return tuple(getattr(self, p) for p in self._tp__typed_properties)
        except AttributeError:
            raise NotImplementedError
672585
private static Wrapper resolveAmbiguousWrapper(Set<Wrapper> candidates,
            Class<?>[] paramTypes) {
        // Identify which parameter isn't an exact match
        Wrapper w = candidates.iterator().next();

        int nonMatchIndex = 0;
        Class<?> nonMatchClass = null;

        for (int i = 0; i < paramTypes.length; i++) {
            if (w.getParameterTypes()[i] != paramTypes[i]) {
                nonMatchIndex = i;
                nonMatchClass = paramTypes[i];
                break;
            }
        }

        for (Wrapper c : candidates) {
           if (c.getParameterTypes()[nonMatchIndex] ==
                   paramTypes[nonMatchIndex]) {
               // Methods have different non-matching parameters
               // Result is ambiguous
               return null;
           }
        }

        if (nonMatchClass == null) {
            // Since null is ambiguous, return the most general method, if possible.
            Class<?> mostGeneralType = null;
            Wrapper mostGeneralMethod = null;
            boolean generalMatchFound = false;
            for (Wrapper c : candidates) {
                Class<?> candidateType = c.getParameterTypes()[nonMatchIndex];
                if (mostGeneralType == null) {
                    mostGeneralType = candidateType;
                    mostGeneralMethod = c;
                } else if (candidateType.isAssignableFrom(mostGeneralType)) {
                    mostGeneralType = candidateType;
                    mostGeneralMethod = c;
                    generalMatchFound = true;
                } else if (mostGeneralType.isAssignableFrom(candidateType)) {
                    generalMatchFound = true;
                }
            }
            if (generalMatchFound) {
                return mostGeneralMethod;
            } else {
                // Could not determine the most general method
                return null;
            }
        }

        // Can't be null
        Class<?> superClass = nonMatchClass.getSuperclass();
        while (superClass != null) {
            for (Wrapper c : candidates) {
                if (c.getParameterTypes()[nonMatchIndex].equals(superClass)) {
                    // Found a match
                    return c;
                }
            }
            superClass = superClass.getSuperclass();
        }

        // Treat instances of Number as a special case
        Wrapper match = null;
        if (Number.class.isAssignableFrom(nonMatchClass)) {
            for (Wrapper c : candidates) {
                Class<?> candidateType = c.getParameterTypes()[nonMatchIndex];
                if (Number.class.isAssignableFrom(candidateType) ||
                        candidateType.isPrimitive()) {
                    if (match == null) {
                        match = c;
                    } else {
                        // Match still ambiguous
                        match = null;
                        break;
                    }
                }
            }
        }

        return match;
    }
13502
def getEnvironmentFromNameAndProtocol(studyname, protocolname):
    
    # StudyName =    "TEST (1) (DEV)"
    # ProtocolName = "TEST (1)"
    # Raw Env      =           "(DEV)"

    raw_env = studyname[len(protocolname) :].strip()

    if "(" in raw_env:
        l_brace_pos = raw_env.rfind("(")
        r_brace_pos = raw_env.rfind(")")
        return raw_env[l_brace_pos + 1 : r_brace_pos]
    else:
        return raw_env
220360
def get_unicode_property(value, prop=None, is_bytes=False):
    """"""

    if prop is not None:
        prop = unidata.unicode_alias['_'].get(prop, prop)
        try:
            if prop == 'generalcategory':
                return get_gc_property(value, is_bytes)
            elif prop == 'script':
                return get_script_property(value, is_bytes)
            elif prop == 'scriptextensions':
                return get_script_extension_property(value, is_bytes)
            elif prop == 'block':
                return get_block_property(value, is_bytes)
            elif prop == 'binary':
                return get_binary_property(value, is_bytes)
            elif prop == 'bidiclass':
                return get_bidi_property(value, is_bytes)
            elif prop == 'bidipairedbrackettype':
                return get_bidi_paired_bracket_type_property(value, is_bytes)
            elif prop == 'age':
                return get_age_property(value, is_bytes)
            elif prop == 'eastasianwidth':
                return get_east_asian_width_property(value, is_bytes)
            elif PY35 and prop == 'indicpositionalcategory':
                return get_indic_positional_category_property(value, is_bytes)
            elif not PY35 and prop == 'indicmatracategory':
                return get_indic_positional_category_property(value, is_bytes)
            elif prop == 'indicsyllabiccategory':
                return get_indic_syllabic_category_property(value, is_bytes)
            elif prop == 'hangulsyllabletype':
                return get_hangul_syllable_type_property(value, is_bytes)
            elif prop == 'decompositiontype':
                return get_decomposition_type_property(value, is_bytes)
            elif prop == 'canonicalcombiningclass':
                return get_canonical_combining_class_property(value, is_bytes)
            elif prop == 'numerictype':
                return get_numeric_type_property(value, is_bytes)
            elif prop == 'numericvalue':
                return get_numeric_value_property(value, is_bytes)
            elif prop == 'joiningtype':
                return get_joining_type_property(value, is_bytes)
            elif prop == 'joininggroup':
                return get_joining_group_property(value, is_bytes)
            elif prop == 'graphemeclusterbreak':
                return get_grapheme_cluster_break_property(value, is_bytes)
            elif prop == 'linebreak':
                return get_line_break_property(value, is_bytes)
            elif prop == 'sentencebreak':
                return get_sentence_break_property(value, is_bytes)
            elif prop == 'wordbreak':
                return get_word_break_property(value, is_bytes)
            elif prop == 'nfcquickcheck':
                return get_nfc_quick_check_property(value, is_bytes)
            elif prop == 'nfdquickcheck':
                return get_nfd_quick_check_property(value, is_bytes)
            elif prop == 'nfkcquickcheck':
                return get_nfkc_quick_check_property(value, is_bytes)
            elif prop == 'nfkdquickcheck':
                return get_nfkd_quick_check_property(value, is_bytes)
            elif PY37 and prop == 'verticalorientation':
                return get_vertical_orientation_property(value, is_bytes)
            else:
                raise ValueError('Invalid Unicode property!')
        except Exception:
            raise ValueError('Invalid Unicode property!')

    try:
        return get_gc_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_script_extension_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_block_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_binary_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_is_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_in_property(value, is_bytes)
    except Exception:
        pass

    raise ValueError('Invalid Unicode property!')
962370
def doc(self):
        """"""
        return self._pv.doc or inspect.getdoc(
            getattr(type(self._target), self._pv.property, None)) or ''
900652
def get_canonical_combining_class_property(value, is_bytes=False):
    """"""

    obj = unidata.ascii_canonical_combining_class if is_bytes else unidata.unicode_canonical_combining_class

    if value.startswith('^'):
        negated = value[1:]
        value = '^' + unidata.unicode_alias['canonicalcombiningclass'].get(negated, negated)
    else:
        value = unidata.unicode_alias['canonicalcombiningclass'].get(value, value)

    return obj[value]
570859
def see_doc(obj_with_doc):
    """"""
    def decorator(fn):
        fn.__doc__ = obj_with_doc.__doc__
        return fn
    return decorator