text stringlengths 0 828 |
|---|
print(""Run 'yass serve' to view the site"") |
footer()" |
4472,"def create_page(pagename): |
"""""" Create a new page Omit the extension, it will create it as .jade file """""" |
page = pagename.lstrip(""/"").rstrip(""/"") |
_, _ext = os.path.splitext(pagename) |
# If the file doesn't have an extension, we'll just create one |
if not _ext or _ext == """": |
page += "".jade"" |
if not page.endswith(PAGE_FORMAT): |
error(""Can't create '%s'"" % page) |
print(""Invalid filename format"") |
print(""Filename must be in: '%s'"" % "" | "".join(PAGE_FORMAT)) |
else: |
engine = Yass(CWD) |
markup = ""jade"" |
if page.endswith("".md""): |
markup = ""md"" |
if page.endswith("".html""): |
markup = ""html"" |
dest_file = os.path.join(engine.pages_dir, page) |
dest_dir = os.path.dirname(dest_file) |
content = TPL_HEADER |
content += TPL_BODY[markup] |
if os.path.isfile(dest_file): |
error(""File exists already"") |
print(""Location: %s"" % dest_file) |
else: |
if not os.path.isdir(dest_dir): |
os.makedirs(dest_dir) |
with open(dest_file, ""w"") as f: |
f.write(content) |
print(""New page created: '%s'"" % page) |
print(""Location: %s"" % dest_file) |
footer()" |
4473,"def serve(port, no_livereload, open_url): |
""""""Serve the site """""" |
engine = Yass(CWD) |
if not port: |
port = engine.config.get(""local_server.port"", 8000) |
if no_livereload is None: |
no_livereload = True if engine.config.get(""local_server.livereload"") is False else False |
if open_url is None: |
open_url = False if engine.config.get(""local_server.open_url"") is False else True |
print(""Serving at %s"" % port) |
print(""Livereload is %s"" % (""OFF"" if no_livereload else ""ON"")) |
def build_static(): |
engine.build_static() |
def build_pages(): |
engine.build_pages() |
engine.build() |
server = Server() |
if no_livereload is False: |
server.watch(engine.static_dir + ""/"", build_static) |
server.watch(engine.pages_dir + ""/"", build_pages) |
server.watch(engine.templates_dir + ""/"", build_pages) |
server.watch(engine.data_dir + ""/"", build_pages) |
server.serve(open_url_delay=open_url, port=port, root=engine.build_dir)" |
4474,"def get_map_location(self): |
""""""Get the location of the player, converted to world coordinates. |
:return: a tuple (x, y, z). |
"""""" |
map_data = self.get_map() |
(bounds_e, bounds_n), (bounds_w, bounds_s) = map_data[""continent_rect""] |
(map_e, map_n), (map_w, map_s) = map_data[""map_rect""] |
assert bounds_w < bounds_e |
assert bounds_n < bounds_s |
assert map_w < map_e |
assert map_n < map_s |
meters_to_inches = 39.3701 |
x, y, z = self.fAvatarPosition |
map_x = bounds_w + ((x * meters_to_inches - map_w) / |
(map_e - map_w) * (bounds_e - bounds_w)) |
map_y = bounds_n + ((-z * meters_to_inches - map_n) / |
(map_s - map_n) * (bounds_s - bounds_n)) |
map_z = y * meters_to_inches |
return map_x, map_y, map_z" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.