本文整理汇总了Python中Path.Path类的典型用法代码示例。如果您正苦于以下问题:Python Path类的具体用法?Python Path怎么用?Python Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_control
def make_control(argv):
# return a Bunch
print argv
if len(argv) not in (3, 4):
usage('invalid number of arguments')
pcl = ParseCommandLine(argv)
arg = Bunch(
base_name=argv[0].split('.')[0],
geo=pcl.get_arg('--geo'),
test=pcl.has_arg('--test'),
)
if arg.geo is None:
usage('missing --arg')
if arg.geo not in ('census_tract', 'zip5'):
usage('invalid GEO value: ', + arg.geo)
random_seed = 123456
random.seed(random_seed)
path = Path() # use the default dir_input
debug = False
return Bunch(
arg=arg,
debug=debug,
max_sale_price=85e6, # according to Wall Street Journal
path=path,
path_out_csv=path.dir_working() + arg.base_name + '-' + arg.geo + '.csv',
path_out_occurs=path.dir_working() + arg.base_name + '-' + arg.geo + '-occurs.pickle',
random_seed=random_seed,
test=arg.test,
)
示例2: __init__
def __init__(s):
#Dane:
win=Window("Point",0,0,600,600)
master=win.getMaster()
desk=Desk(master)
C=desk.getC()
p1=Point(100,100)
p2=Point(200,100)
p3=Point(200,200)
p4=Point(100,200)
desk.addPoint(p1)
desk.addPoint(p2)
desk.addPoint(p3)
desk.addPoint(p4)
path=Path()
path.addPoint(p1)
path.addPoint(p2)
path.addPoint(p3)
path.addPoint(p4)
desk.addPath(path)
win.loop()
示例3: make_control
def make_control(argv):
# return a Bunch
print argv
if len(argv) not in (1, 2):
usage('invalid number of arguments')
pcl = ParseCommandLine(argv)
arg = Bunch(
base_name=argv[0].split('.')[0],
test=pcl.has_arg('--test'),
)
random_seed = 123456
random.seed(random_seed)
path = Path() # use the default dir_input
debug = False
return Bunch(
arg=arg,
debug=debug,
path=path,
path_out=path.dir_working() + arg.base_name + '-' + 'derived.csv',
random_seed=random_seed,
test=arg.test,
)
示例4: getCustomPath
def getCustomPath(latitude, longitude, end_place):
startCoord = Coordinate()
startCoord.latitude = latitude
startCoord.longitude = longitude
#Get all coordinate in the database for our end place
end_coordinates = Coordinate.getAllForBuilding(end_place)
if len(end_coordinates) == 0:
raise Exception(end_place + " is not a building in our database")
#Figure out the two closest coordinates
(startCoord, endCoord) = DB.getClosestCoords([startCoord], end_coordinates)
#Find all floor plans for our end place
#floorPlans = []
#floors = Floor.getAllForBuilding(end_place)
#for floor in floors:
# floorPlans.append(floor.floor_map)
#Get building information for our end place
building = Building()
building.loadFromID(end_place)
#Build path object to pass back
path = Path()
path.startCoord = startCoord.__dict__
path.endCoord = endCoord.__dict__
path.floorPlans = building.floorPlans
path.buildingInfo = building.__dict__
return path.__dict__
示例5: execute
def execute(self, g):
gcodes = self.printer.config.get("Macros", "G29").split("\n")
self.printer.path_planner.wait_until_done()
for gcode in gcodes:
G = Gcode({"message": gcode, "prot": g.prot})
self.printer.processor.execute(G)
self.printer.path_planner.wait_until_done()
logging.debug(self.printer.probe_heights)
# Remove the offset from the probed points
if self.printer.probe_points[0]["X"] == 0 and self.printer.probe_points[0]["Y"] == 0:
# If the origin is located in the first probe point, remove that.
self.printer.probe_heights -= self.printer.probe_heights[0]
else:
# Else, remove the lowest.
self.printer.probe_heights -= min(self.printer.probe_heights)
# Log the found heights
for k, v in enumerate(self.printer.probe_points):
self.printer.probe_points[k]["Z"] = self.printer.probe_heights[k]
logging.info("Found heights: ")
logging.info(self.printer.probe_points)
# Add 'S'=simulate To not update the bed matrix.
if not g.has_letter("S"):
# Update the bed compensation matrix
Path.update_autolevel_matrix(self.printer.probe_points, self.printer.probe_heights)
logging.debug("New Bed level matrix: ")
logging.debug(Path.matrix_bed_comp)
示例6: import_gtfs
def import_gtfs(cls, directory):
Agency.import_agencies(directory)
Calendar.import_calendars(directory)
Stop.import_stops(directory)
Path.import_paths(directory)
Route.import_routes(directory)
Trip.import_trips(directory)
Frequency.import_frequencies(directory)
示例7: export_gtfs
def export_gtfs(cls, directory):
Agency.write_agencies(directory)
Calendar.write_calendars(directory)
Stop.write_stops(directory)
Route.write_routes(directory)
Trip.write_trips(directory)
Frequency.write_frequencies(directory)
Path.write_paths(directory)
示例8: PathfinderPlayer
class PathfinderPlayer(sf.CircleShape):
def __init__(self, x, y):
sf.CircleShape.__init__(self)
self.radius = 10
self.position = (x, y)
self.outline_color = sf.Color.BLUE
self.outline_thickness = 5
self.path = None
def update(self, sight_blockers, mouse_position):
self.path = Path(self.position, mouse_position)
self.path.update(sight_blockers)
示例9: close
def close(self):
self._is_open = False
self._dbname = None
# clear everything
Agency.clear()
Calendar.clear()
Stop.clear()
Path.clear()
Route.clear()
TripRoute.clear()
Trip.clear()
Frequency.clear()
Picture.clear()
示例10: __init__
def __init__(self, start=Coordinate(), end=Coordinate(), id=None, classes=None):
"""
@param start: Coordinate of the first point of the line
@type start: Coordinate
@param end: Coordinate of the last point of the line
@type end: Coordinate
@param id: The unique ID to be used in the SVG document
@type id: string
@param classes: Classnames to be used in the SVG document
@type classes: string or sequence of strings
"""
Path.__init__(self, (start, end), id=id, classes=classes)
self.tag = u"line"
示例11: jarviswalk
def jarviswalk(points):
"""Implementation of Jarvis Walk aka Gift wrapping algorithm.
Based on the article http://en.wikipedia.org/wiki/Gift_wrapping_algorithm
"""
hull = Path()
xsorted = sorted(points, key=lambda point: point.x)
hull.addPoint(xsorted[0])
while True:
nextP = None
maxLinearPoint = None
maxLinearDistance = -1.0
possiblePoints = filter(lambda p: p not in hull.points[1:], xsorted)
for p in possiblePoints:
if p is hull.points[-1]: continue
line = Line(hull.points[-1], p)
allright, localMaxLinear, localMaxLinearDistance = allrightAndMaxLinearPoint(line, xsorted)
if allright:
nextP = p
break
if localMaxLinear is not None and localMaxLinearDistance != -1.0 and localMaxLinearDistance > maxLinearDistance:
maxLinearPoint, maxLinearDistance = (localMaxLinear, localMaxLinearDistance)
assert(nextP is not None or (maxLinearPoint is not None and maxLinearDistance > 0.0))
if nextP is not None:
hull.addPoint(nextP)
else:
hull.addPoint(maxLinearPoint)
if hull.isConnected():
break
return hull
示例12: _home_internal
def _home_internal(self, axis):
""" Private method for homing a set or a single axis """
logging.debug("homing " + str(axis))
path_back = {}
path_center = {}
path_zero = {}
speed = Path.home_speed[0]
for a in axis:
if not self.printer.steppers[a].has_endstop:
logging.debug("Skipping homing for " + str(a))
continue
path_back[a] = -self.travel_length[a]
path_center[a] = -self.center_offset[a]
path_zero[a] = 0
speed = min(speed, Path.home_speed[Path.axis_to_index(a)])
# Move until endstop is hit
p = RelativePath(path_back, speed, True)
self.add_path(p)
# Reset position to offset
p = G92Path(path_center, speed)
self.add_path(p)
# Move to offset
p = AbsolutePath(path_zero, speed)
self.add_path(p)
self.wait_until_done()
logging.debug("homing done for " + str(axis))
示例13: set_extruder
def set_extruder(self, ext_nr):
if ext_nr in range(Path.NUM_AXES-3):
logging.debug("Selecting "+str(ext_nr))
Path.steps_pr_meter[3] = self.printer.steppers[
Path.index_to_axis(ext_nr+3)
].get_steps_pr_meter()
self.native_planner.setExtruder(ext_nr)
示例14: readPubKeyFromCache
def readPubKeyFromCache(_keyHash):
path = Path.certificates(_keyHash)
if not os.path.isfile(path) : return ''
with open(path, 'rb') as f :
str_ = f.read()
(head, sep, tail) = str_.partition('\n-----END PUBLIC KEY-----')
return ''.join((head, sep)).encode('utf-8')
示例15: _go_to_home
def _go_to_home(self, axis):
"""
go to the designated home position
do this as a separate call from _home_internal due to delta platforms
performing home in cartesian mode
"""
path_home = {}
speed = Path.home_speed[0]
accel = self.printer.acceleration[0]
for a in axis:
path_home[a] = self.home_pos[a]
speed = min(abs(speed), abs(Path.home_speed[Path.axis_to_index(a)]))
logging.debug("Home: %s" % path_home)
# Move to home position
p = AbsolutePath(path_home, speed, accel, True, False, False, False)
self.add_path(p)
self.wait_until_done()
# Due to rounding errors, we explicitly set the found
# position to the right value.
# Reset (final) position to offset
p = G92Path(path_home, speed)
self.add_path(p)
return