同步操作将从 RT-Thread/rt-thread 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
## File : utils.py# This file is part of RT-Thread RTOS# COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License along# with this program; if not, write to the Free Software Foundation, Inc.,# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.## Change Logs:# Date Author Notes# 2015年01月20日 Bernard Add copyright information#import sysimport osdef splitall(loc):"""Return a list of the path components in loc. (Used by relpath_).The first item in the list will be either ``os.curdir``, ``os.pardir``, empty,or the root directory of loc (for example, ``/`` or ``C:\\).The other items in the list will be strings.Adapted from *path.py* by Jason Orendorff."""parts = []while loc != os.curdir and loc != os.pardir:prev = locloc, child = os.path.split(prev)if loc == prev:breakparts.append(child)parts.append(loc)parts.reverse()return partsdef _make_path_relative(origin, dest):"""Return the relative path between origin and dest.If it's not possible return dest.If they are identical return ``os.curdir``Adapted from `path.py <http://www.jorendorff.com/articles/python/path/>`_ by Jason Orendorff."""origin = os.path.abspath(origin).replace('\\', '/')dest = os.path.abspath(dest).replace('\\', '/')#orig_list = splitall(os.path.normcase(origin))# Don't normcase dest! We want to preserve the case.dest_list = splitall(dest)#if orig_list[0] != os.path.normcase(dest_list[0]):# Can't get here from there.return dest## Find the location where the two paths start to differ.i = 0for start_seg, dest_seg in zip(orig_list, dest_list):if start_seg != os.path.normcase(dest_seg):breaki += 1## Now i is the point where the two paths diverge.# Need a certain number of "os.pardir"s to work up# from the origin to the point of divergence.segments = [os.pardir] * (len(orig_list) - i)# Need to add the diverging part of dest_list.segments += dest_list[i:]if len(segments) == 0:# If they happen to be identical, use os.curdir.return os.curdirelse:# return os.path.join(*segments).replace('\\', '/')return os.path.join(*segments)def xml_indent(elem, level=0):i = "\n" + level*" "if len(elem):if not elem.text or not elem.text.strip():elem.text = i + " "if not elem.tail or not elem.tail.strip():elem.tail = ifor elem in elem:xml_indent(elem, level+1)if not elem.tail or not elem.tail.strip():elem.tail = ielse:if level and (not elem.tail or not elem.tail.strip()):elem.tail = i
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。