本文整理汇总了Python中GPS类的典型用法代码示例。如果您正苦于以下问题:Python GPS类的具体用法?Python GPS怎么用?Python GPS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GPS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: json_read
def json_read(self, config):
self.reset()
j = json.loads(config)
# load img config
if j["imgpath"] is not None:
self.map_load(j["imgpath"])
else:
self.map_unset()
# walk speed
if "walk_speed" in j:
self.walk_speed = j["walk_speed"]
# load reference points
if j["A"] is not None:
la, lo = GPS.sex2dec(j["A"]["coord"])
self.set_ref("A", j["A"]["xy"][0], j["A"]["xy"][1], la, lo)
else:
self.unset_ref("A")
if j["H"] is not None:
la, lo = GPS.sex2dec(j["H"]["coord"])
self.set_ref("H", j["H"]["xy"][0], j["H"]["xy"][1], la, lo)
else:
self.unset_ref("H")
if j["V"] is not None:
la, lo = GPS.sex2dec(j["V"]["coord"])
self.set_ref("V", j["V"]["xy"][0], j["V"]["xy"][1], la, lo)
else:
self.unset_ref("V")
# load last route
self.route = j["route"]
示例2: on_exit
def on_exit(status):
"""
Called when gnatname exited.
Reload the project view if it succeed.
"""
if not status:
GPS.execute_action("reload project")
示例3: do_exit
def do_exit(timeout):
""" Force an exit of GPS right now, logging as an error the contents
of the Messages window. This is useful for capturing more traces
for stalled tests that are about to get killed by rlimit.
"""
timeout.remove()
simple_error(GPS.Console("Messages").get_text())
GPS.exit(force=1)
示例4: goto_declaration_body
def goto_declaration_body():
"""
Jump to the declaration of the current entity. If the cursor
is already on the declaration, jump to the body/implementation
of the entity instead.
"""
current_file = GPS.current_context().file()
current_line = GPS.current_context().location().line()
try:
entity = GPS.current_context().entity()
decl = entity.declaration().file()
decl_line = entity.declaration().line()
GPS.Editor.mark_current_location()
if current_file == decl and current_line == decl_line:
body = entity.body().file()
body_line = entity.body().line()
GPS.Editor.edit(body.name(),
line=body_line,
column=entity.body().column())
else:
GPS.Editor.edit(decl.name(),
line=decl_line,
column=entity.declaration().column())
GPS.Editor.mark_current_location()
except:
print "Not found %s:%s:%s" % (name, current_file.path, line)
GPS.Editor.edit(current_file.other_file().path)
示例5: __init__
def __init__(self, tool_name, default_args):
"""
Initializes a new instance of the class :class:`TargetConnector` by
creating a build target associated to ``tool_name``, with
``default_args`` used as default arguments.
"""
xml = r"""
<target model="target connector" category="Bareboard"
name="%s">
<launch-mode>MANUALLY_WITH_NO_DIALOG</launch-mode>
<command-line>
<arg>%s</arg>""" % (tool_name, tool_name)
for arg in default_args:
xml += r"""<arg>%s</arg>\n""" % (arg)
xml += """</command-line>
</target>"""
try:
super(TargetConnector, self).__init__(tool_name)
except GPS.Exception:
GPS.parse_xml(xml)
super(TargetConnector, self).__init__(tool_name)
示例6: go_to_spec
def go_to_spec(prj = XReqProject()):
context = GPS.current_context()
file = context.file()
line_no = context.location().line()
buffer = GPS.EditorBuffer.get(file)
#GPS.Console().write ("%s line %d\n" % (file.name(), line_no))
if not buffer.is_modified():
filename = file.name()
delete = False
else:
filename = GPS.dump(buffer.get_chars())
delete = True
args = ["xreq", "--partial", "--step-matching", "--step", prj.steps_dir(), filename]
p = subprocess.Popen(args, stdout=subprocess.PIPE)
step_file = None
step_line = None
for line in p.stdout.readlines():
m = re.match('^Step Matching: "(.*):([0-9]+)" matches "(.*):([0-9]+)" procedure (.*)$', line)
if m:
l = int(m.group(2))
if l > line_no:
break
else:
#GPS.Console().write ("line %d match %s (%s:%d)\n" % (
# int(m.group(2)), m.group(5), m.group(3), int(m.group(4))));
step_file = m.group(3)
step_line = int(m.group(4))
p.stdout.close()
if delete:
os.remove(filename)
if step_file:
open_file(step_file, step_line)
示例7: reload_file
def reload_file (menu):
"""Reload the currently edited file in python.
If the file has not been imported yet, import it initially.
Otherwise, reload the current version of the file."""
try:
file = GPS.current_context().file()
module=os.path.splitext (os.path.basename (file.name()))[0]
## The actual import and reload must be done in the context of the
## GPS console so that they are visible there. The current function
## executes in a different context, and would not impact the GPS
## console as a result otherwise.
## We cannot use execfile(...), since that would be the equivalent
## of "from ... import *", not of "import ..."
if sys.modules.has_key (module):
GPS.exec_in_console ("reload (sys.modules[\"" + module + "\"])")
else:
try:
sys.path.index (os.path.dirname (file.name()))
except:
sys.path = [os.path.dirname (file.name())] + sys.path
mod = __import__ (module)
# This would import in the current context, not what we want
# exec (compile ("import " + module, "<cmdline>", "exec"))
## The proper solution is to execute in the context of the GPS console
GPS.exec_in_console ("import " + module)
except:
pass ## Current context is not a file
示例8: register_doc
def register_doc():
GPS.parse_xml ("""
<documentation_file>
<name>http://www.python.org/doc/2.4.2/tut/tut.html</name>
<descr>Python tutorial</descr>
<menu>/Python/Python Tutorial</menu>
<category>Scripts</category>
</documentation_file>
<documentation_file>
<shell lang="python">python_support.show_python_library()</shell>
<descr>Python Library</descr>
<menu>/Python/Python Library</menu>
<category>Scripts</category>
</documentation_file>""")
if has_pygtk:
GPS.parse_xml ("""
<documentation_file>
<name>http://www.pygtk.org/pygtk2tutorial/index.html</name>
<descr>PyGTK tutorial</descr>
<menu>/Python/PyGTK Tutorial</menu>
<category>Scripts</category>
</documentation_file>
<documentation_file>
<name>http://www.pygtk.org/pygtk2reference/index.html</name>
<descr>PyGTK Reference Manual</descr>
<menu>/Python/PyGTK Reference Manual</menu>
<category>Scripts</category>
</documentation_file>""")
示例9: close_editors
def close_editors():
"""
Save and close all source editors.
"""
GPS.execute_action("/File/Save More/All")
for ed in GPS.EditorBuffer.list():
ed.close(True)
示例10: setup
def setup(self):
GPS.parse_xml(targets)
GPS.Hook("compilation_finished").add(self.on_compilation_finished)
GPS.Hook("preferences_changed").add(self.on_preferences_changed)
# Initialize trusted_mode and other preferences
self.on_preferences_changed(None)
示例11: __init__
def __init__(self):
# Whether we trust that there are no links in the project hierarchy
self.trusted_mode = True
cross_ref_runtime.create(
"Cross references in runtime files",
'boolean',
"Index files in the runtime for cross references queries",
False)
# When we support python, we add support for the --runtime attribute.
# This is not supported in GNAT Bench though
xml = self.xml
xml = xml.replace(
"<!-- Runtime_switch support -->",
"<arg>%python(cross_references.runtime_switch())</arg>")
GPS.parse_xml(xml)
GPS.Hook("project_view_changed").add(self.on_project_view_changed)
GPS.Hook("compilation_finished").add(self.on_compilation_finished)
GPS.Hook("preferences_changed").add(self.on_preferences_changed)
GPS.Hook("rsync_finished").add(self.on_rsync_finished)
self.gnatinspect_launch_registered = False
self.gnatinspect_already_running = False
# Initialize self.trusted_mode and other preferences
self.on_preferences_changed(None)
# An action for the menu item /Build/Recompute Xref Info
gps_utils.make_interactive(
lambda *args: self.recompute_xref(quiet=False),
name="recompute xref info")
示例12: attempt_up
def attempt_up(count=1):
line = GPS.current_context().location().line()
if line - count > 0:
file = GPS.current_context().file().name()
GPS.Editor.cursor_set_position(file, line - count)
return True
else:
return False
示例13: gps_fatal_error
def gps_fatal_error(msg):
"""Unconditional error"""
global exit_status
exit_status = FAILURE
GPS.Logger('TESTSUITE').log(msg)
GPS.exit(force=1)
raise Exception("Fatal Error: %s" % msg)
示例14: internalSpawn
def internalSpawn(self, filestr, project, recursive=False):
if GPS.Preference('General-Auto-Save').get():
# Force, since otherwise we get a modal dialog while within
# a GPS action, which gtk+ doesn't like
modified = GPS.Project.root().is_modified(recursive=True)
GPS.MDI.save_all(force=True)
if modified:
GPS.Project.root().recompute()
self.full_output = ""
opts_project = project
opts = opts_project.get_attribute_as_list(
"switches", package="check", index="ada")
if len(opts) == 0:
opts = opts_project.get_attribute_as_list(
"default_switches", package="check", index="ada")
if len(opts) == 0:
opts_project = GPS.Project.root()
opts = opts_project.get_attribute_as_list(
"switches", package="check", index="ada")
if len(opts) == 0:
opts = opts_project.get_attribute_as_list(
"default_switches", package="check", index="ada")
# We need a rules file if none was specified in the project.
need_rules_file = True
if len(opts) != 0:
for opt in opts:
res = re.split("^\-from\=(.*)$", opt)
if len(res) > 1:
# we cd to the project's dir before creating the file,
# as this will then correctly resolve if the file is
# relative to the project's dir
olddir = GPS.pwd()
GPS.cd(opts_project.file().directory())
self.rules_file = GPS.File(res[1])
GPS.cd(olddir)
need_rules_file = False
if need_rules_file:
# Display a dialog, but without using run(), since we are
# running a GPS action in the task manager and that would
# crash GPS on some platforms
selector = rulesSelector(project.name(), self.rules_file)
def on_response(dialog, response_id):
if response_id == Gtk.ResponseType.OK:
self.rules_file = selector.get_file()
dialog.destroy()
self.on_spawn(filestr, project, recursive)
else:
dialog.destroy()
selector.connect('response', on_response)
selector.show_all()
else:
self.on_spawn(filestr, project, recursive)
示例15: close_editors_except_current
def close_editors_except_current():
"""
Save and close all source editors, except the curret one.
"""
buffer = GPS.EditorBuffer.get(open=False)
GPS.execute_action("/File/Save More/All")
for ed in GPS.EditorBuffer.list():
if ed != buffer:
ed.close(True)