Returns the answers to the lab classes.
554671
def answer(part, module='mlai2014.json'):
    """"""
    marks = json.load(open(os.path.join(data_directory, module), 'rb'))
    return marks['Lab '  + str(part+1)]
864049
def get_study_items(self):
        """"""
        study_items = set()
        for rec in self.goea_results:
            study_items |= rec.study_items
        return study_items
504378
def tolist(self):
        
        return [[x.val for x in theclass.items] for theclass in self.classes]
709215
def _getSuitableClasses(self, data):
        """"""
        classes = None
        if data[EI.CLASS] == ELFCLASS.BITS_32:
            if data[EI.DATA] == ELFDATA.LSB:
                classes = LSB_32
            elif data[EI.DATA] == ELFDATA.MSB:
                classes = MSB_32

        elif data[EI.CLASS] == ELFCLASS.BITS_64:
            if data[EI.DATA] == ELFDATA.LSB:
                classes = LSB_64
            elif data[EI.DATA] == ELFDATA.MSB:
                classes = MSB_64

        return classes
218016
def get_labs(format, open_cage_api_key):
    """"""

    diybiolabs_soup = data_from_diybio_org()
    diybiolabs = {}

    rows_list = []
    continents_dict = {}
    continents_order = 0
    ranges_starting_points = []

    # Load all the DIYBio Labs
    # By first parsing the html

    # Parse table rows
    for row in diybiolabs_soup.select("table tr"):
        cells = row.find_all('td')
        rows_list.append(cells)

    # Find the continents in order to iterate over their children td
    for k, row in enumerate(rows_list):
        for col in row:
            if col.find('h3'):
                for h3 in col.findAll('h3'):
                    ranges_starting_points.append(k)
                    continents_dict[continents_order] = h3.get_text()
                    continents_order += 1

    # Find the rows of each continent
    ranges = {}
    for k, j in enumerate(reversed(ranges_starting_points)):
        if k < len(ranges_starting_points) - 1:
            ranges[k] = {"start": ranges_starting_points[k],
                         "end": ranges_starting_points[k + 1]}
        else:
            # The last continent, Oceania
            ranges[k] = {"start": ranges_starting_points[k],
                         "end": len(rows_list)}

    # Iterate over the range of each continent to find the Labs
    for i in ranges:
        # The +1 just avoids the H3 line
        for j in range(ranges[i]["start"] + 1, ranges[i]["end"]):
            # Avoid empty rows by measuring the lenght of the content of each cell and with a boolean check
            rules = [len(n) == 0 for n in rows_list[j]]
            if False in rules:
                current_lab = DiyBioLab()
                current_lab.city = rows_list[j][1].contents[0].encode('utf-8')
                # Data from the USA is not really well formatted
                if continents_dict[i] == "USA-EAST" or continents_dict[
                        i] == "USA-WEST":
                    current_lab.state = rows_list[j][2].contents[0].replace(
                        " ", "").encode('utf-8')
                else:
                    current_lab.country_code = rows_list[j][2].contents[
                        0].encode('utf-8')
                current_lab.url = rows_list[j][3].contents[0].attrs['href']
                # Each lab is identified by the simplified url
                slug = current_lab.url
                if "http://" in slug:
                    slug = slug.replace("http://", "")
                elif "https://" in slug:
                    slug = slug.replace("https://", "")
                if "www." in slug:
                    slug = slug.replace("www.", "")
                current_lab.name = slug
                current_lab.slug = slug

                # Data from the USA is not really well formatted
                if continents_dict[i] == "USA-EAST" or continents_dict[i] == "USA-WEST":
                    current_lab.continent = "North America"
                    current_lab.country_code = "USA"
                    current_lab.country = "United States of America"
                    current_lab.state = us.states.lookup(
                        current_lab.state).name

                # Get address from city
                address = get_location(query=current_lab.city, format="direct", api_key=open_cage_api_key)
                current_lab.continent = address["continent"]
                current_lab.latitude = address["latitude"]
                current_lab.longitude = address["longitude"]
                current_lab.address_1 = address["address_1"]
                current_lab.country = address["country"]
                current_lab.country_code = address["country_code"]
                current_lab.latitude = address["latitude"]
                current_lab.longitude = address["longitude"]
                current_lab.county = address["county"]
                current_lab.postal_code = address["postal_code"]
                current_lab.state = address["state"]

                # Add the lab to the list
                diybiolabs[slug] = current_lab
                del current_lab

    # Return a dictionary / json
    if format.lower() == "dict":
        output = {}
        for j in diybiolabs:
            output[j] = diybiolabs[j].__dict__
    # Return a geojson
    elif format.lower() == "geojson" or format.lower() == "geo":
        labs_list = []
        for l in diybiolabs:
            single = diybiolabs[l].__dict__
            single_lab = Feature(
                type="Feature",
                geometry=Point((single["latitude"], single["longitude"])),
                properties=single)
            labs_list.append(single_lab)
        output = dumps(FeatureCollection(labs_list))
    # Return a Pandas DataFrame
    elif format.lower() == "pandas" or format.lower() == "dataframe":
        output = {}
        for j in diybiolabs:
            output[j] = diybiolabs[j].__dict__
        # Transform the dict into a Pandas DataFrame
        output = pd.DataFrame.from_dict(output)
        # Put labs names as the index, to make it coherent with other APIs
        output = output.transpose()
    # Return an object
    elif format.lower() == "object" or format.lower() == "obj":
        output = diybiolabs
    # Default: return an oject
    else:
        output = diybiolabs
    # Return a proper json
    if format.lower() == "json":
        output = json.dumps(diybiolabs)
    return output
443946
def _lab_data(self):
        
        portal = self.context.portal_url.getPortalObject()
        lab = self.context.bika_setup.laboratory
        lab_address = lab.getPostalAddress() \
            or lab.getBillingAddress() \
            or lab.getPhysicalAddress()
        if lab_address:
            _keys = ['address', 'city', 'state', 'zip', 'country']
            _list = ["<div>%s</div>" % lab_address.get(v) for v in _keys
                     if lab_address.get(v)]
            lab_address = "".join(_list)
        else:
            lab_address = ''

        return {'obj': lab,
                'title': to_utf8(lab.Title()),
                'url': to_utf8(lab.getLabURL()),
                'address': to_utf8(lab_address),
                'confidence': lab.getConfidence(),
                'accredited': lab.getLaboratoryAccredited(),
                'accreditation_body': to_utf8(lab.getAccreditationBody()),
                'accreditation_logo': lab.getAccreditationBodyLogo(),
                'logo': "%s/logo_print.png" % portal.absolute_url()}
1105967
def get_topclasses(cls):
    """"""
    bases = [c for c in inspect.getmro(cls)
             if c.__module__.startswith('pycbc') and c != cls]
    return ', '.join(['{}.{}'.format(c.__module__, c.__name__) for c in bases])
1014345
def get_predicates(self, class_):
        
        return self.client.get_predicates(
            class_=class_, controller=self.controller)
1179001
def get_grade_systems(self):
        
        if self.retrieved:
            raise errors.IllegalState('List has already been retrieved.')
        self.retrieved = True
        return objects.GradeSystemList(self._results, runtime=self._runtime)
695938
def get_labs(format):
    """"""

    hackerspaces_json = data_from_hackaday_io(hackaday_io_labs_map_url)
    hackerspaces = {}

    # Load all the Hackerspaces
    for i in hackerspaces_json:
        current_lab = Hackerspace()
        current_lab.id = i["id"]
        current_lab.url = "https://hackaday.io/hackerspace/" + current_lab.id
        current_lab.name = i["name"]
        if len(i["description"]) != 0:
            current_lab.description = i["description"]
        elif len(i["summary"]) != 0:
            current_lab.description = i["summary"]
        current_lab.created_at = i["moments"]["exact"]

        # Check if there are coordinates
        if i["latlon"] is not None:
            latlon = json.loads(i["latlon"])
            current_lab.latitude = latlon["lat"]
            current_lab.longitude = latlon["lng"]
            # Get country, county and city from them
            country = geolocator.reverse(
                [latlon["lat"], latlon["lng"]])
            current_lab.country = country.raw[
                "address"]["country"]
            current_lab.address = country.raw["display_name"]
            current_lab.address_1 = country.raw["display_name"]
            current_lab.country_code = country.raw[
                "address"]["country_code"]
            current_lab.county = country.raw[
                "address"]["state_district"]
            current_lab.city = country.raw[
                "address"]["city"]
            current_lab.postal_code = country.raw[
                "address"]["postcode"]
        else:
            # For labs without a location or coordinates
            # add 0,0 as coordinates
            current_lab.latitude = 0.0
            current_lab.longitude = 0.0

        # Add the lab
        hackerspaces[i["name"]] = current_lab

    # Return a dictiornary / json
    if format.lower() == "dict" or format.lower() == "json":
        output = {}
        for j in hackerspaces:
            output[j] = hackerspaces[j].__dict__
    # Return a geojson
    elif format.lower() == "geojson" or format.lower() == "geo":
        labs_list = []
        for l in hackerspaces:
            single = hackerspaces[l].__dict__
            single_lab = Feature(
                type="Feature",
                geometry=Point((single["latitude"], single["longitude"])),
                properties=single)
            labs_list.append(single_lab)
        output = dumps(FeatureCollection(labs_list))
    # Return a Pandas DataFrame
    elif format.lower() == "pandas" or format.lower() == "dataframe":
        output = {}
        for j in hackerspaces:
            output[j] = hackerspaces[j].__dict__
        # Transform the dict into a Pandas DataFrame
        output = pd.DataFrame.from_dict(output)
        output = output.transpose()
    # Return an object
    elif format.lower() == "object" or format.lower() == "obj":
        output = hackerspaces
    # Default: return an oject
    else:
        output = hackerspaces
    # Return a proper json
    if format.lower() == "json":
        output = json.dumps(output)
    return output
825317
def get_assessments(self):
        
        assessments = []
        response = self.http.get('/Assessment')
        for assessment in response:
            assessments.append(Schemas.Assessment(assessment=assessment))
        return assessments
115501
def get_answers(self):
        
        # Implemented from template for osid.repository.Asset.get_asset_contents_template
        return AnswerList(
            self._my_map['answers'],
            runtime=self._runtime,
            proxy=self._proxy)
1108981
def get_plugins_qs(cls):
        
        if is_plugin_point(cls):
            point_pythonpath = cls.get_pythonpath()
            return Plugin.objects.filter(point__pythonpath=point_pythonpath,
                                         status=ENABLED).\
                order_by('index')
        else:
            raise Exception(_('This method is only available to plugin point '
                              'classes.'))
732463
private List<ClassDocImpl> getClasses(boolean filtered) {
        if (allClasses != null && !filtered) {
            return allClasses;
        }
        if (allClassesFiltered != null && filtered) {
            return allClassesFiltered;
        }
        ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
        for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
            if (e.sym != null) {
                ClassSymbol s = (ClassSymbol)e.sym;
                ClassDocImpl c = env.getClassDoc(s);
                if (c != null && !c.isSynthetic())
                    c.addAllClasses(classes, filtered);
            }
        }
        if (filtered)
            return allClassesFiltered = classes.toList();
        else
            return allClasses = classes.toList();
    }
84714
def get_labs(format):
    """"""

    labs_json = data_from_makery_info(makery_info_labs_api_url)
    labs = {}

    # Load all the FabLabs
    for i in labs_json["labs"]:
        current_lab = MakeryLab()
        current_lab.address_1 = i["address_1"]
        current_lab.address_2 = i["address_2"]
        current_lab.address_notes = i["address_notes"]
        current_lab.avatar = i["avatar"]
        current_lab.blurb = i["blurb"]
        current_lab.capabilities = i["capabilities"]
        current_lab.city = i["city"]
        current_lab.country_code = i["country_code"]
        current_lab.county = i["county"]
        current_lab.description = i["description"]
        current_lab.email = i["email"]
        current_lab.header_image_src = i["header_image_src"]
        current_lab.id = i["id"]
        current_lab.kind_name = i["kind_name"]
        # Some labs do not have coordinates
        if i["latitude"] is None or i["longitude"] is None:
            address = i["address_1"] + i["city"] + i["country_code"]
            try:
                location = geolocator.geocode(address)
                current_lab.latitude = location.latitude
                current_lab.longitude = location.longitude
            except:
                try:
                    location = geolocator.geocode(i["city"])
                    current_lab.latitude = location.latitude
                    current_lab.longitude = location.longitude
                except:
                    # For labs without a city, add 0,0 as coordinates
                    current_lab.latitude = 0.0
                    current_lab.longitude = 0.0
        else:
            current_lab.latitude = i["latitude"]
            current_lab.longitude = i["longitude"]
        current_lab.links = i["links"]
        current_lab.name = i["name"]
        current_lab.parent_id = i["parent_id"]
        current_lab.phone = i["phone"]
        current_lab.postal_code = i["postal_code"]
        current_lab.slug = i["slug"]
        current_lab.url = i["url"]
        # Add the lab
        labs[i["slug"]] = current_lab

    # Return a dictiornary / json
    if format.lower() == "dict" or format.lower() == "json":
        output = {}
        for j in labs:
            output[j] = labs[j].__dict__
    # Return a geojson
    elif format.lower() == "geojson" or format.lower() == "geo":
        labs_list = []
        for l in labs:
            single = labs[l].__dict__
            single_lab = Feature(
                type="Feature",
                geometry=Point((single["latitude"], single["longitude"])),
                properties=single)
            labs_list.append(single_lab)
        output = dumps(FeatureCollection(labs_list))
    # Return a Pandas DataFrame
    elif format.lower() == "pandas" or format.lower() == "dataframe":
        output = {}
        for j in labs_list:
            output[j] = labs_list[j].__dict__
        # Transform the dict into a Pandas DataFrame
        output = pd.DataFrame.from_dict(output)
        output = output.transpose()
    # Return an object
    elif format.lower() == "object" or format.lower() == "obj":
        output = labs
    # Default: return an oject
    else:
        output = labs
    # Return a proper json
    if format.lower() == "json":
        output = json.dumps(output)
    return output
474769
def get_children(self):
        """"""
        if self.is_leaf():
            return get_result_class(self.__class__).objects.none()
        return get_result_class(self.__class__).objects.filter(
            depth=self.depth + 1,
            path__range=self._get_children_path_interval(self.path)
        ).order_by(
            'path'
        )
156185
final public function get_answers() {
        global $DB;
        if ($this->answers === null) {
            $this->answers = array();
            $answers = $DB->get_records('lesson_answers', array('pageid'=>$this->properties->id, 'lessonid'=>$this->lesson->id), 'id');
            if (!$answers) {
                // It is possible that a lesson upgraded from Moodle 1.9 still
                // contains questions without any answers [MDL-25632].
                // debugging(get_string('cannotfindanswer', 'lesson'));
                return array();
            }
            foreach ($answers as $answer) {
                $this->answers[count($this->answers)] = new lesson_page_answer($answer);
            }
        }
        return $this->answers;
    }