text stringlengths 0 93.6k |
|---|
@classmethod |
def get_downloaded(cls,directory=os.getcwd()): |
file_list = [] |
for content in os.listdir(directory): |
if content.endswith(".gpx"): |
file_list.append(content.split(".gpx")[0]) |
return file_list |
def download_trails(self, directory = os.getcwd()): |
downloaded = HikingProject.get_downloaded(directory) |
for trail in self.trails: |
gpx_id = trail["id"] |
if str(gpx_id) not in downloaded: |
url = "https://www.hikingproject.com/trail/gpx/%s" % str(gpx_id) |
print("downloading:%s" % url) |
gpxfile = directory+"/"+str(gpx_id) + ".gpx" |
try: |
data = self.session_requests.get(url, headers = dict(referer = url), allow_redirects = True) |
except: |
raise Exception("Could not download gpx for %i" % gpx_id) |
with open(gpxfile, 'w+') as f: |
f.write(data.text) |
def login(self, email, password): |
self.session_requests = requests.session() |
login_url = "https://www.hikingproject.com/auth/login" |
email_url = "https://www.hikingproject.com/auth/login/email" |
result = self.session_requests.get(login_url) |
tree = html.fromstring(result.text) |
authenticity_token = list(set(tree.xpath("//input[@name='_token']/@value")))[0] |
payload = {"email":email, "pass":password, "_token":authenticity_token} |
result = self.session_requests.post( |
email_url, |
data = payload, |
headers = dict(referer=login_url)) |
if result.status_code != 200: |
raise Exception("Unable to Login to HikingProject. Please check login credentials") |
# <FILESEP> |
# |
# Copyright 2015 Hernán M. Foffani |
# |
# Licensed under the Apache License, Version 2.0 (the "License"); |
# you may not use this file except in compliance with the License. |
# You may obtain a copy of the License at |
# |
# http://www.apache.org/licenses/LICENSE-2.0 |
# |
# Unless required by applicable law or agreed to in writing, software |
# distributed under the License is distributed on an "AS IS" BASIS, |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
# See the License for the specific language governing permissions and |
# limitations under the License. |
# |
# |
import sys |
import pddlpy |
import argparse |
parser = argparse.ArgumentParser(description='Demo PDDLPY.') |
parser.add_argument('demonumber', metavar='N', type=int, nargs='+', |
help='the number(s) of the demo') |
def run_demo(demonumber): |
print('===') |
print(f'Run DEMO {demonumber}') |
domainfile = "./examples-pddl/domain-0%d.pddl" % demonumber |
problemfile = "./examples-pddl/problem-0%d.pddl" % demonumber |
domprob = pddlpy.DomainProblem(domainfile, problemfile) |
print() |
print("DOMAIN PROBLEM") |
print("objects") |
print("\t", domprob.worldobjects()) |
print("operators") |
print("\t", list( domprob.operators() )) |
print("init",) |
print("\t", domprob.initialstate()) |
print("goal",) |
print("\t", domprob.goals()) |
print() |
ops_to_test = { 1:"op2", 2:"move", 3:"move", 4:"move", 5:"A1", 6:"op2" } |
op = ops_to_test[demonumber] |
print("ground for operator", op, "applicable if (adjacent loc1 loc2)") |
for o in domprob.ground_operator(op): |
if ("adjacent","loc1","loc2") in o.precondition_pos: |
print() |
print( "\tvars", o.variable_list ) |
print( "\tpre+", o.precondition_pos ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.